{"id":19580442,"url":"https://github.com/dod-iac/terraform-aws-ecs-cluster","last_synced_at":"2025-04-27T08:32:18.227Z","repository":{"id":41390022,"uuid":"356397552","full_name":"dod-iac/terraform-aws-ecs-cluster","owner":"dod-iac","description":"An AWS ECS Cluster","archived":false,"fork":false,"pushed_at":"2022-09-13T23:49:31.000Z","size":71,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T23:32:25.356Z","etag":null,"topics":["aws","ecs","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/dod-iac/ecs-cluster/aws","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/dod-iac.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}},"created_at":"2021-04-09T21:03:10.000Z","updated_at":"2023-01-20T05:04:30.000Z","dependencies_parsed_at":"2023-01-18T06:45:22.908Z","dependency_job_id":null,"html_url":"https://github.com/dod-iac/terraform-aws-ecs-cluster","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dod-iac%2Fterraform-aws-ecs-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dod-iac%2Fterraform-aws-ecs-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dod-iac%2Fterraform-aws-ecs-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dod-iac%2Fterraform-aws-ecs-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dod-iac","download_url":"https://codeload.github.com/dod-iac/terraform-aws-ecs-cluster/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251112549,"owners_count":21538162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["aws","ecs","terraform","terraform-module"],"created_at":"2024-11-11T07:26:01.916Z","updated_at":"2025-04-27T08:32:15.933Z","avatar_url":"https://github.com/dod-iac.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n## Usage\n\nCreates an ECS cluster backed by EC2 instances.\n\n```hcl\nmodule \"ecs_instance_role\" {\n  source = \"dod-iac/ecs-instance-role/aws\"\n\n  name = format(\"app-%s-ecs-instance-role-%s\", var.application, var.environment)\n\n  tags  = {\n    Application = var.application\n    Environment = var.environment\n    Automation  = \"Terraform\"\n  }\n}\n\nresource \"aws_iam_instance_profile\" \"ecs_instance_role\" {\n  name = module.ecs_instance_role.name\n  role = module.ecs_instance_role.name\n}\n\nmodule \"ecs_cluster\" {\n  source = \"dod-iac/ecs-cluster/aws\"\n\n  iam_instance_profile = aws_iam_instance_profile.ecs_instance_role.arn\n  name = format(\"app-%s-%s\", var.application, var.environment)\n  subnet_ids = var.subnet_ids\n  vpc_id      = var.vpc_id\n\n  tags  = {\n    Application = var.application\n    Environment = var.environment\n    Automation  = \"Terraform\"\n  }\n}\n```\n\nBy default, the ECS Cluster bootstraps Amazon Linux 2 images.  If using a custom AMI, modify the `image_id` and `user_data` variables as applicable.  If using AWS GovCloud, `ami-b1e0dad0` is equivalent to the default Amazon Linux 2 image in AWS commercial.\n\nChanges to the desired\\_capacity, min\\_size, and max\\_size configuration of the Auto Scaling group are ignored by Terraform.  These parameters can be updated via the AWS Console, API, or CLI.\n\nTo connect to an EC2 instance that is part of the ECS cluster, set the subnet\\_ids to public subnets and set the key\\_name to the name of a key pair.\n\nIf you receive a `ECS Service Linked Role does not exist.` error, then you are missing the ECS service Linked Role for your AWS account.  This role only needs to be created once per acocunt, and can be created using the terraform resource shown below.\n\n```hcl\nresource \"aws_iam_service_linked_role\" \"ecs\" {\n  aws_service_name = \"ecs.amazonaws.com\"\n}\n\n## Testing\n\nRun all terratest tests using the `terratest` script.  If using `aws-vault`, you could use `aws-vault exec $AWS_PROFILE -- terratest`.  The `AWS_DEFAULT_REGION` environment variable is required by the tests.  Use `TT_SKIP_DESTROY=1` to not destroy the infrastructure created during the tests.  Use `TT_VERBOSE=1` to log all tests as they are run.  The go test command can be executed directly, too.\n\n## Known Issues\n\nDue to a bug with the terraform provider, manually delete the Autoscaling group when destroying the infrastructure.  See [#5278](https://github.com/hashicorp/terraform-provider-aws/issues/5278).\n\n## Terraform Version\n\nTerraform 0.13. Pin module version to ~\u003e 1.0.0 . Submit pull-requests to main branch.\n\nTerraform 0.11 and 0.12 are not supported.\n\n## License\n\nThis project constitutes a work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105.  However, because the project utilizes code licensed from contributors and other third parties, it therefore is licensed under the MIT License.  See LICENSE file for more information.\n```\n\n## Requirements\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"requirement_terraform\"\u003e\u003c/a\u003e [terraform](#requirement\\_terraform) | \u003e= 0.13 |\n| \u003ca name=\"requirement_aws\"\u003e\u003c/a\u003e [aws](#requirement\\_aws) | \u003e= 3.74.0, \u003c 5.0 |\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_aws\"\u003e\u003c/a\u003e [aws](#provider\\_aws) | \u003e= 3.74.0, \u003c 5.0 |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [aws_autoscaling_group.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group) | resource |\n| [aws_ecs_capacity_provider.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_capacity_provider) | resource |\n| [aws_ecs_cluster.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster) | resource |\n| [aws_ecs_cluster_capacity_providers.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster_capacity_providers) | resource |\n| [aws_kms_alias.exec_command](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource |\n| [aws_kms_key.exec_command](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |\n| [aws_launch_configuration.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_configuration) | resource |\n| [aws_security_group.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |\n| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |\n| [aws_iam_policy_document.exec_command](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |\n| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_associate_public_ip_address\"\u003e\u003c/a\u003e [associate\\_public\\_ip\\_address](#input\\_associate\\_public\\_ip\\_address) | Associate a public ip address with an instance in a VPC | `bool` | `false` | no |\n| \u003ca name=\"input_autoscaling_enabled_metrics\"\u003e\u003c/a\u003e [autoscaling\\_enabled\\_metrics](#input\\_autoscaling\\_enabled\\_metrics) | Metrics enabled by default for the autoscaling group | `list(string)` | \u003cpre\u003e[\u003cbr\u003e  \"GroupAndWarmPoolDesiredCapacity\",\u003cbr\u003e  \"GroupAndWarmPoolTotalCapacity\",\u003cbr\u003e  \"GroupDesiredCapacity\",\u003cbr\u003e  \"GroupInServiceCapacity\",\u003cbr\u003e  \"GroupInServiceInstances\",\u003cbr\u003e  \"GroupMaxSize\",\u003cbr\u003e  \"GroupMinSize\",\u003cbr\u003e  \"GroupPendingCapacity\",\u003cbr\u003e  \"GroupPendingInstances\",\u003cbr\u003e  \"GroupStandbyCapacity\",\u003cbr\u003e  \"GroupStandbyInstances\",\u003cbr\u003e  \"GroupTerminatingCapacity\",\u003cbr\u003e  \"GroupTerminatingInstances\",\u003cbr\u003e  \"GroupTotalCapacity\",\u003cbr\u003e  \"GroupTotalInstances\",\u003cbr\u003e  \"WarmPoolDesiredCapacity\",\u003cbr\u003e  \"WarmPoolMinSize\",\u003cbr\u003e  \"WarmPoolPendingCapacity\",\u003cbr\u003e  \"WarmPoolTerminatingCapacity\",\u003cbr\u003e  \"WarmPoolTotalCapacity\",\u003cbr\u003e  \"WarmPoolWarmedCapacity\"\u003cbr\u003e]\u003c/pre\u003e | no |\n| \u003ca name=\"input_autoscaling_protect_from_scale_in\"\u003e\u003c/a\u003e [autoscaling\\_protect\\_from\\_scale\\_in](#input\\_autoscaling\\_protect\\_from\\_scale\\_in) | Allows setting instance protection. The Auto Scaling Group will not select instances with this setting for termination during scale in events. | `bool` | `true` | no |\n| \u003ca name=\"input_aws_launch_configuration_name_prefix\"\u003e\u003c/a\u003e [aws\\_launch\\_configuration\\_name\\_prefix](#input\\_aws\\_launch\\_configuration\\_name\\_prefix) | The prefix of the name of the AWS Launch configuration. If not specified, defaults to the value of \"name-\". | `string` | `\"\"` | no |\n| \u003ca name=\"input_desired_capacity\"\u003e\u003c/a\u003e [desired\\_capacity](#input\\_desired\\_capacity) | The number of Amazon EC2 instances that should be running in the group. | `number` | `1` | no |\n| \u003ca name=\"input_iam_instance_profile\"\u003e\u003c/a\u003e [iam\\_instance\\_profile](#input\\_iam\\_instance\\_profile) | n/a | `string` | n/a | yes |\n| \u003ca name=\"input_image_id\"\u003e\u003c/a\u003e [image\\_id](#input\\_image\\_id) | The EC2 image ID to launch.  If using AWS GovCloud, \"ami-b1e0dad0\" is equivalent. | `string` | `\"ami-0e999cbd62129e3b1\"` | no |\n| \u003ca name=\"input_instance_type\"\u003e\u003c/a\u003e [instance\\_type](#input\\_instance\\_type) | n/a | `string` | `\"m5.large\"` | no |\n| \u003ca name=\"input_key_name\"\u003e\u003c/a\u003e [key\\_name](#input\\_key\\_name) | Name of EC2 key pair used to connect to the instances. | `string` | `\"\"` | no |\n| \u003ca name=\"input_max_size\"\u003e\u003c/a\u003e [max\\_size](#input\\_max\\_size) | The maximum size of the Auto Scaling Group. | `number` | `1` | no |\n| \u003ca name=\"input_min_size\"\u003e\u003c/a\u003e [min\\_size](#input\\_min\\_size) | The minimum size of the Auto Scaling Group. | `number` | `1` | no |\n| \u003ca name=\"input_name\"\u003e\u003c/a\u003e [name](#input\\_name) | The name of the cluster (up to 255 letters, numbers, hyphens, and underscores). | `string` | n/a | yes |\n| \u003ca name=\"input_root_block_device_volume_size\"\u003e\u003c/a\u003e [root\\_block\\_device\\_volume\\_size](#input\\_root\\_block\\_device\\_volume\\_size) | Size of the root block device volume in gibibytes (GiB) used by the EC2 instances in the ECS cluster. | `number` | `32` | no |\n| \u003ca name=\"input_security_groups\"\u003e\u003c/a\u003e [security\\_groups](#input\\_security\\_groups) | Additional security groups to add to the launch configuration | `list(string)` | `[]` | no |\n| \u003ca name=\"input_subnet_ids\"\u003e\u003c/a\u003e [subnet\\_ids](#input\\_subnet\\_ids) | The ids of the VPC subnets used by the EC2 instances in the ECS cluster. | `list(string)` | n/a | yes |\n| \u003ca name=\"input_tags\"\u003e\u003c/a\u003e [tags](#input\\_tags) | Tags applied to resources part of the ECS Cluster. | `map(string)` | `{}` | no |\n| \u003ca name=\"input_target_capacity\"\u003e\u003c/a\u003e [target\\_capacity](#input\\_target\\_capacity) | The target utilization for the capacity provider. A number between 1 and 100. | `number` | `50` | no |\n| \u003ca name=\"input_user_data\"\u003e\u003c/a\u003e [user\\_data](#input\\_user\\_data) | The user data provided when launching instances.  If not defined, the userdata.tpl template file is used. | `string` | `\"\"` | no |\n| \u003ca name=\"input_vpc_id\"\u003e\u003c/a\u003e [vpc\\_id](#input\\_vpc\\_id) | The id of the VPC used by the EC2 instances in the ECS cluster. | `string` | n/a | yes |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_autoscaling_group_arn\"\u003e\u003c/a\u003e [autoscaling\\_group\\_arn](#output\\_autoscaling\\_group\\_arn) | The ARN of the EC2 Auto Scaling group. |\n| \u003ca name=\"output_autoscaling_group_name\"\u003e\u003c/a\u003e [autoscaling\\_group\\_name](#output\\_autoscaling\\_group\\_name) | The name of the EC2 Auto Scaling group. |\n| \u003ca name=\"output_aws_kms_alias_arn_exec_command\"\u003e\u003c/a\u003e [aws\\_kms\\_alias\\_arn\\_exec\\_command](#output\\_aws\\_kms\\_alias\\_arn\\_exec\\_command) | The Amazon Resource Name (ARN) of the Execute Command key alias. |\n| \u003ca name=\"output_aws_kms_alias_name_exec_command\"\u003e\u003c/a\u003e [aws\\_kms\\_alias\\_name\\_exec\\_command](#output\\_aws\\_kms\\_alias\\_name\\_exec\\_command) | The display name of the Execute Command alias. |\n| \u003ca name=\"output_aws_kms_key_arn_exec_command\"\u003e\u003c/a\u003e [aws\\_kms\\_key\\_arn\\_exec\\_command](#output\\_aws\\_kms\\_key\\_arn\\_exec\\_command) | The Amazon Resource Name (ARN) of the Execute Command key. |\n| \u003ca name=\"output_ecs_cluster_arn\"\u003e\u003c/a\u003e [ecs\\_cluster\\_arn](#output\\_ecs\\_cluster\\_arn) | The Amazon Resource Name (ARN) of the AWS ECS cluster. |\n| \u003ca name=\"output_ecs_cluster_name\"\u003e\u003c/a\u003e [ecs\\_cluster\\_name](#output\\_ecs\\_cluster\\_name) | The name of the AWS ECS cluster. |\n| \u003ca name=\"output_security_group_id\"\u003e\u003c/a\u003e [security\\_group\\_id](#output\\_security\\_group\\_id) | The id of the AWS Security Group for the AWS ECS cluster. |\n\u003c!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdod-iac%2Fterraform-aws-ecs-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdod-iac%2Fterraform-aws-ecs-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdod-iac%2Fterraform-aws-ecs-cluster/lists"}