{"id":48211096,"url":"https://github.com/techservicesillinois/terraform-aws-ec2","last_synced_at":"2026-04-04T18:48:33.368Z","repository":{"id":35830880,"uuid":"186689919","full_name":"techservicesillinois/terraform-aws-ec2","owner":"techservicesillinois","description":"Provides an Amazon Elastic Compute Cloud (EC2) virtual server","archived":false,"fork":false,"pushed_at":"2025-07-22T21:53:04.000Z","size":29,"stargazers_count":2,"open_issues_count":1,"forks_count":5,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-07-22T23:32:12.282Z","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/techservicesillinois.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-14T19:49:32.000Z","updated_at":"2025-07-22T21:48:23.000Z","dependencies_parsed_at":"2025-07-22T23:33:53.248Z","dependency_job_id":null,"html_url":"https://github.com/techservicesillinois/terraform-aws-ec2","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/techservicesillinois/terraform-aws-ec2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techservicesillinois%2Fterraform-aws-ec2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techservicesillinois%2Fterraform-aws-ec2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techservicesillinois%2Fterraform-aws-ec2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techservicesillinois%2Fterraform-aws-ec2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techservicesillinois","download_url":"https://codeload.github.com/techservicesillinois/terraform-aws-ec2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techservicesillinois%2Fterraform-aws-ec2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31409470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: 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":"2026-04-04T18:48:33.270Z","updated_at":"2026-04-04T18:48:33.353Z","avatar_url":"https://github.com/techservicesillinois.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Terraform actions status](https://github.com/techservicesillinois/terraform-aws-ec2/workflows/terraform/badge.svg)](https://github.com/techservicesillinois/terraform-aws-ec2/actions)\n\n# ec2\n\nProvides an Elastic Computing Cloud (EC2) virtual server instance,\nand optional Route 53 aliases.\nThis module only supports single-instance servers.\n\nFor more information, see the documentation on the Terraform\n[aws_instance](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) resource.\n\nExample usage (simple case)\n-----------------\n\n```hcl\nmodule \"instance\" {\n  source = \"git@github.com:techservicesillinois/terraform-aws-ec2\"\n\n  name        = \"example\"\n  subnet_type = \"public\"\n  vpc         = \"vpc_name\"\n}\n\n```\nExample usage (with resized root volume and storage type)\n-----------------\n\n```hcl\nmodule \"instance\" {\n  source = \"git@github.com:techservicesillinois/terraform-aws-ec2\"\n\n  name        = \"example\"\n  subnet_type = \"public\"\n  vpc         = \"vpc_name\"\n  \n  # Resize root volume to 16 gb and use gp3 storage.\n  root_block_device = {\n    volume_size = 16\n    volume_type = \"gp3\"\n  }\n}\n```\n\nExample usage (alias block with Elastic IP assignment)\n-----------------\n\n```hcl\nmodule \"instance\" {\n  source = \"git@github.com:techservicesillinois/terraform-aws-ec2\"\n\n  alias = [\n    {\n    hostname = \"example\"\n    domain   = \"mydomain.example.com\"\n    }\n  ]\n\n  eip = {\n    name     = \"existing_eip_name\"\n    create   = false\n  }\n\n  name        = \"example\"\n  subnet_type = \"public\"\n  vpc         = \"vpc_name\"\n}\n```\n\n**NOTE:** If you stop and start the EC2 instance from the console, command line interface, or API, the instance's IP address will change, but the alias record will not change. **This behavior causes the Route53 record to point to an IP address no longer associated with the EC2 instance.**\n\nAvoid this by specifying an `eip` block, which attaches an Elastic IP address\nthat persists until destroyed. This Elastic IP address can be created at the time the EC2 instance is created. Alternatively, to have an \nElastic IP address which persists unchanged even after the EC2 instance is \ntorn down and rebuilt, create it in advance and look it up by name.\n\nExample usage (with EBS volume)\n-----------------\n\n```hcl\nmodule \"instance\" {\n  source = \"git@github.com:techservicesillinois/terraform-aws-ec2\"\n\n  name        = \"example\"\n  subnet_type = \"public\"\n  vpc         = \"vpc_name\"\n\n  # Mount block storage device at /scratch.\n  ebs_volume = {\n    device_name = \"/dev/xvdf\"\n    mount_point = \"/scratch\"\n    volume_id   = \"vol-cab005eb1ab\"\n  }\n}\n```\n\nExample usage (with EFS file system)\n-----------------\n\n```hcl\nmodule \"instance\" {\n  source = \"git@github.com:techservicesillinois/terraform-aws-ec2\"\n\n  name        = \"example\"\n  subnet_type = \"public\"\n  vpc         = \"vpc_name\"\n \n  # Mount EFS file system at /mnt.\n  efs_file_system = {\n    file_system_id = \"fs-deadb33f\"\n    mount_point    = \"/mnt\"\n    source_path    = \"/\"\n  }\n}\n```\n\nArgument Reference\n-----------------\n\nThe following arguments are supported:\n\n* `name` - (Required) Name to assign to EC2 instance.\n\n* `vpc` - (Required) The name of the virtual private cloud to be\nassociated with the instance.\n\n* `alias` – (Optional) An [alias](#alias) block used to define a Route 53\n\"A\" record that points to the EC2 instance(s).\n\n* `ami_name_filter` - (Optional) List of image names to filter for\ncandidate AMIs.\n\n* `ami_virtualization_type_filter` - (Optional) List of virtualization\ntypes to filter for candidate AMIs.\n\n* `ami_image_owner` - (Optional) List of Owner IDs to filter for\ncandidate AMIs.\n\n* `associate_public_ip_address` - (Optional) Boolean specifying whether\npublic IP address is to be assigned. Default: true\n\n* `cidr_blocks` - (Optional) List of CIDR blocks to have inbound SSH access\nto the EC2 instance.\n\n* `ebs_volume` – (Optional) An [ebs\\_volume](#ebs_volume) block used to define the EBS volume to be attached to the EC2 instance(s).\n\n* `efs_file_system` – (Optional) An [efs\\_file\\_system](#efs_file_system) block used to define the EFS file system to be attached to the EC2 instance(s).\n\n* `eip` – (Optional) An [eip](#eip) block used to create or look up an Elastic IP to attach to the EC2 instance. To omit the Elastic IP entirely, do not specify an `eip` block.\n\n* `iam_instance_profile` - (Optional) IAM instance profile for this EC2 instance.\n\n* `instance_type` - (Required) EC2 instance type.\n\n* `key_name` - (Optional) SSH key (if any) to assign to EC2 instance.\n\n* `ports` - (Optional) Ports to be opened on the EC2 instance.\n\n* `root_block_device` – (Optional) A [root_block_device](#root_block_device) block used to define characteristics of the root volume.\n\n* `security_groups` - (Optional) List of security group names.\n\n* `subnet_type` - (Required) Subnet type (e.g., 'campus', 'private', 'public') for resource placement.\n\n* `tags` - (Optional) A mapping of tags to assign where supported.\n\n* `template_file` - (Optional) User data template file.\n\n* `private_ip` - (Optional) Private IP address to associate with the instance in a VPC.\n\n`alias`\n-------\n\nAn `alias` block supports the following keys:\n\n* `domain` - (Required) The name of the Route 53 zone in which the record\nis to be created.\n\n* `hostname` – (Optional) The name of the host to be created in the\nspecified Route 53 zone. Default: the EC2 instance name (i.e., what\nappears in the `name` attribute).\n\n* `private_zone` – (Optional) Specify if the alias is to reside in a \nprivate zone inside the virtual private cloud (VPC). Default: false.\n\n* `ttl` - (Optional) Time in seconds for DNS lookup to be cached. Default: 60.\n\n* `use_private_ip` (Optional) Route53 record should use private rather than public IP address. Default: false.\n\nNote that if the `hostname` is omitted, it will default to the `name`\nspecified for the EC2 instance. This default will not work unless each\n`domain` specified is different, since multiple records with the same\nname can not be added in the same Route53 zone.\n\n`ebs_volume`\n-------\n\nAn `ebs_volume` block supports the following keys:\n\n* `device_name` - (Required) The device file name to which the EBS volume will be attached on the virtual host. The value is passed to the `user_data` template as `ebs_device_name`.\n\n* `mount_point` – (Required) The path at which the EBS volume is to be mounted on the virtual host. The value is passed to the `user_data` template as `ebs_mount_point`.\n\n* `volume_id` - (Required) The EBS volume ID. The value is *not* passed to the `user_data` template, because the volume attachment takes place before the `user_data` file is run, thereby rendering it useless after the virtual server is booted.\n\n`efs_file_system`\n-------\n\nAn `efs_file_system` block supports the following keys:\n\n* `file_system_id` - (Required) The EFS file system ID. The derived file system name is passed to the `user_data` template as `efs_file_system_name`.\n\n* `mount_point` – (Required) The path at which the EFS file system is to be mounted on the virtual host.  The value is passed to the `user_data` template as `efs_mount_point`.\n\n* `source_path` - (Required) The path relative to the EFS file system root to be mounted on the virtual host. The value is passed to the `user_data` template as `efs_source_path`.\n\n`eip`\n-------\n\nAn `eip` block supports the following keys:\n\n* `name` - (Optional) The name of the Elastic IP address to attach to this EC2 instance. This may be the name of an existing Elastic IP already created in a prior step, \nor a name to give to a new Elastic IP address to be created at the time the \nEC2 instance is created. Default is the name of the EC2 instance (given in \nthe `name` argument above).\n\n* `create` - (Required) Set to true if the Elastic IP is to be created for the\nEC2 instance. Set to false if the Elastic IP already exists and is to be looked up.\n\n`root_block_device`\n-------------------\n\n* `delete_on_termination`- (Optional) Whether the volume should be destroyed on instance termination. Defaults to true.\n\n* `encrypted` - (Optional) Whether to enable volume encryption. Defaults to false.\n\n* `iops` - (Optional) Amount of provisioned IOPS. Only valid for volume_type of io1, io2 or gp3.\n\n* `kms_key_id` - (Optional) Amazon Resource Name (ARN) of the KMS Key to use when encrypting the volume.\n\n* `throughput` - (Optional) Throughput to provision for a volume in mebibytes per second (MiB/s). This is only valid for volume_type of gp3.\n\n* `volume_size` - (Optional) Size of the volume in gibibytes (GiB).\n\n* `volume_type` - (Optional) Type of volume. Valid values include standard, gp2, gp3, io1, io2, sc1, or st1. Defaults to gp2.\n\nTemplate variables\n-------\nThe following variables are passed to the `user_data` template, and are\ntherefore available to the process by which the virtual host is provisioned.\n\n* `ebs_device_name`\n* `ebs_mount_point`\n* `efs_file_system_name`\n* `efs_mount_point`\n* `efs_source_path`\n* `hostname`\n\nFor details about the data populated into the `ebs_` and `efs_` variables,\nplease see the descriptions above for the [ebs\\_volume](#ebs_volume) and [efs\\_file\\_system](#efs_file_system) blocks.\n\nThe `hostname` contains a fully-qualified domain name computed from the\nfirst entry in the `alias` block, if any is defined.\n\nAttributes Reference\n--------------------\n\nThe following attributes are exported:\n\n* `alias` – A list of fully qualified domain names (if any) for each alias created for the instance.\n\n* `availability_zone` – The AWS availability zone to which the instance is assigned.\n\n* `private_dns` - The private DNS name assigned to the instance.\n\n* `private_ip` - The private IP address assigned to the instance\n\n* `public_dns` - The public DNS name assigned to the instance, if any.\n\n* `public_ip` - The public IP address assigned to the instance, if any.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechservicesillinois%2Fterraform-aws-ec2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechservicesillinois%2Fterraform-aws-ec2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechservicesillinois%2Fterraform-aws-ec2/lists"}