{"id":21429609,"url":"https://github.com/dc-tec/terraform-aws-ec2","last_synced_at":"2026-02-24T15:35:04.390Z","repository":{"id":218430038,"uuid":"746374339","full_name":"dc-tec/terraform-aws-ec2","owner":"dc-tec","description":"Terraform AWS EC2 Module","archived":false,"fork":false,"pushed_at":"2024-01-21T21:31:26.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T23:33:34.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dc-tec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"docs/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T21:20:25.000Z","updated_at":"2024-01-21T21:29:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"496d1782-584c-4888-bc39-8a3546960458","html_url":"https://github.com/dc-tec/terraform-aws-ec2","commit_stats":null,"previous_names":["dc-tec/terraform-aws-ec2"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dc-tec/terraform-aws-ec2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-ec2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-ec2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-ec2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-ec2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dc-tec","download_url":"https://codeload.github.com/dc-tec/terraform-aws-ec2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-ec2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29788123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T10:45:18.109Z","status":"ssl_error","status_checked_at":"2026-02-24T10:45:09.911Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:18:28.621Z","updated_at":"2026-02-24T15:35:04.370Z","avatar_url":"https://github.com/dc-tec.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform AWS EC2 Instance Module\nThis module manages the creation of EC2 instances in AWS, along with associated resources like security groups, key pairs, and local files for storing private keys.\n\n## Requirements\n\n- Terraform version 1.7.0 or newer\n- AWS provider version 5.0 or newer\n- TLS provider version 3.0 or newer\n- Local provider version 2.0 or newer\n\n## Providers\n\n- AWS\n- TLS\n- Local\n\n## Resources\n- `aws_region.current`: This data source provides the current region.\n- `aws_security_group.main`: This data source fetches the security group associated with each EC2 instance.\n- `aws_subnet.main`: This data source fetches the subnet associated with each EC2 instance.\n- `tls_private_key.main`: This resource creates a private key for each EC2 instance.\n- `aws_key_pair.main`: This resource creates a key pair for each EC2 instance using the generated private key.\n- `local_file.main`: This resource creates a local file containing the private key for each EC2 instance.\n- `aws_instance.main`: This resource creates the EC2 instances.\n\n## Inputs\n- `ec2_instance_config`: A map where each item represents an EC2 instance configuration.\n\n## Outputs\n- `instance_ids`: The IDs of the created EC2 instances.\n- `key_pair_names`: The names of the created key pairs.\n- `private_key_files`: The paths to the local files containing the private keys.\n\n## Example Usage\nThe module can be used in the following way. Please note that a private/public keypair is created on the local machine. In a later version we will update this so it write to a KMS.\n\n```hcl\nterraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp/aws\"\n      version = \"~\u003e 5.0\"\n    }\n  }\n  required_version = \"\u003e= 1.7.0\"\n}\n\nprovider \"aws\" {\n  region = var.region\n}\n\nlocals {\n  ec2_instance_config = {\n    for ec2_instance_name, ec2_instance_info in var.ec2_instance_config : ec2_instance_name =\u003e {\n      ami                         = ec2_instance_info.ami\n      instance_type               = ec2_instance_info.instance_type\n      security_group_name         = ec2_instance_info.security_group_name\n      subnet_name                 = ec2_instance_info.subnet_name\n      availability_zone           = ec2_instance_info.availability_zone\n      associate_public_ip_address = coalesce(ec2_instance_info.associate_public_ip_address, false)\n      availability_zone           = ec2_instance_info.availability_zone\n    }\n  }\n}\n\nmodule \"ec2\" {\n  source     = \"src\"\n\n  ## EC2 instance configuration\n  ec2_instance_config = local.ec2_instance_config\n}\n```\n\nThe following example TFVars can be used with this module.\n\n```hcl\nec2_instance_config = {\n  \"bastion-dev1\" = {\n    ami                         = \"ami-07355fe79b493752d\"\n    instance_type               = \"t2.micro\"\n    subnet_name                 = \"public1-dev1\"\n    security_group_name         = [\"bastion-dev1\"]\n    availability_zone           = \"eu-west-1a\"\n    associate_public_ip_address = true\n    tags = {\n      \"Name\" = \"bastion-dev1\"\n    }\n  }\n  \"private-ec2-dev1\" = {\n    ami                 = \"ami-07355fe79b493752d\"\n    instance_type       = \"t2.micro\"\n    subnet_name         = \"private1-dev1\"\n    security_group_name = [\"private-dev1\"]\n    availability_zone   = \"eu-west-1a\"\n    tags = {\n      \"Name\" = \"private-ssh-dev1\"\n    }\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdc-tec%2Fterraform-aws-ec2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdc-tec%2Fterraform-aws-ec2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdc-tec%2Fterraform-aws-ec2/lists"}