Skip to content

Commit

Permalink
Merge pull request #25 from hanscg/execute-command-config
Browse files Browse the repository at this point in the history
Support execute command configuration in ECS cluster config
  • Loading branch information
hanscg authored Nov 7, 2023
2 parents a683de6 + 2694ca3 commit 1e42d45
Show file tree
Hide file tree
Showing 49 changed files with 119 additions and 94 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This module uses Semver.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -76,6 +76,7 @@ No modules.
| <a name="input_capacity_providers"></a> [capacity\_providers](#input\_capacity\_providers) | List of short names or full Amazon Resource Names (ARNs) of one or more capacity providers to associate with the cluster. Valid values also include `FARGATE` and `FARGATE_SPOT`. | `list(string)` | `null` | no |
| <a name="input_default_capacity_provider_strategy"></a> [default\_capacity\_provider\_strategy](#input\_default\_capacity\_provider\_strategy) | The capacity provider strategy to use by default for the cluster. Can be one or more. List of map with corresponding items in docs. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster#default_capacity_provider_strategy) | `list(any)` | `[]` | no |
| <a name="input_enable_container_insights"></a> [enable\_container\_insights](#input\_enable\_container\_insights) | Enable container insights. | `bool` | `false` | no |
| <a name="input_execute_command_configuration"></a> [execute\_command\_configuration](#input\_execute\_command\_configuration) | Map with execute command configuration. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster#execute_command_configuration) | `any` | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | Cluster name. | `string` | n/a | yes |
| <a name="input_settings"></a> [settings](#input\_settings) | List of maps with cluster settings. For example, this can be used to enable CloudWatch Container Insights for a cluster. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_cluster#setting) | `list(any)` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Key-value mapping of resource tags. | `map(string)` | `{}` | no |
Expand Down
6 changes: 3 additions & 3 deletions examples/complete-ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -46,7 +46,7 @@ $ terraform apply
|------|--------|---------|
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | 5.13.0 |
| <a name="module_alb_security_group"></a> [alb\_security\_group](#module\_alb\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 3.0 |
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 7.0 |
| <a name="module_asg_autoscaling"></a> [asg\_autoscaling](#module\_asg\_autoscaling) | ../../modules/autoscaling/asg-target-tracking/ecs-reservation | n/a |
| <a name="module_easy_ec2"></a> [easy\_ec2](#module\_easy\_ec2) | ../../modules/simple/ec2 | n/a |
| <a name="module_easy_fargate"></a> [easy\_fargate](#module\_easy\_fargate) | ../../modules/simple/fargate | n/a |
Expand All @@ -56,7 +56,7 @@ $ terraform apply
| <a name="module_ecs_security_group"></a> [ecs\_security\_group](#module\_ecs\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_fargate_service_autoscaling_target"></a> [fargate\_service\_autoscaling\_target](#module\_fargate\_service\_autoscaling\_target) | ../../modules/core/ecs-autoscaling-target | n/a |
| <a name="module_fargate_target_request_autoscaling"></a> [fargate\_target\_request\_autoscaling](#module\_fargate\_target\_request\_autoscaling) | ../../modules/autoscaling/alb-target-tracking/target-requests-count | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
2 changes: 1 addition & 1 deletion examples/complete-ecs/autoscaling.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module "asg_autoscaling" {
source = "../../modules/autoscaling/asg-target-tracking/ecs-reservation"

name = "${local.prefix}-autoscale"
autoscaling_group_name = module.asg.this_autoscaling_group_name
autoscaling_group_name = module.asg.autoscaling_group_id
ecs_cluster_name = module.ecs_cluster.name

enable_cpu_based_autoscaling = true
Expand Down
24 changes: 11 additions & 13 deletions examples/complete-ecs/support_infra.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data "aws_ssm_parameter" "ami_image" {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -17,7 +17,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = var.enable_ipv6
assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand Down Expand Up @@ -127,21 +126,20 @@ resource "aws_lb_listener_rule" "fargate" {

module "asg" {
source = "terraform-aws-modules/autoscaling/aws"
version = "~> 3.0"
version = "~> 7.0"

name = "${local.prefix}-asg"

image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ecs_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 10
desired_capacity = 1
health_check_type = "EC2"
associate_public_ip_address = true
image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ecs_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 10
desired_capacity = 1
health_check_type = "EC2"
user_data = templatefile("../templates/ec2_userdata.tpl", {
ecs_cluster = module.ecs_cluster.name
})
iam_instance_profile = var.instance_profile_arn
iam_instance_profile_arn = var.instance_profile_arn
}
2 changes: 1 addition & 1 deletion examples/complete-ecs/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
6 changes: 3 additions & 3 deletions examples/easy/ec2-alb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To test that it's working:

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -39,11 +39,11 @@ To test that it's working:
|------|--------|---------|
| <a name="module_alb"></a> [alb](#module\_alb) | terraform-aws-modules/alb/aws | 5.13.0 |
| <a name="module_alb_security_group"></a> [alb\_security\_group](#module\_alb\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 3.0 |
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 7.0 |
| <a name="module_easy_ec2"></a> [easy\_ec2](#module\_easy\_ec2) | ../../../modules/simple/ec2 | n/a |
| <a name="module_ec2_security_group"></a> [ec2\_security\_group](#module\_ec2\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
24 changes: 11 additions & 13 deletions examples/easy/ec2-alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ locals {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -29,7 +29,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = var.enable_ipv6
assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand Down Expand Up @@ -107,23 +106,22 @@ module "alb" {

module "asg" {
source = "terraform-aws-modules/autoscaling/aws"
version = "~> 3.0"
version = "~> 7.0"

name = "${local.prefix}-asg"

image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ec2_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 2
desired_capacity = 1
health_check_type = "EC2"
associate_public_ip_address = true
image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ec2_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 2
desired_capacity = 1
health_check_type = "EC2"
user_data = templatefile("../../templates/ec2_userdata.tpl", {
ecs_cluster = module.ecs_cluster.name
})
iam_instance_profile = var.instance_profile_arn
iam_instance_profile_arn = var.instance_profile_arn
}

# This module usage starts here
Expand Down
2 changes: 1 addition & 1 deletion examples/easy/ec2-alb/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
6 changes: 3 additions & 3 deletions examples/easy/ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -43,11 +43,11 @@ $ terraform apply

| Name | Source | Version |
|------|--------|---------|
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 4.0 |
| <a name="module_asg"></a> [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 7.0 |
| <a name="module_easy_ec2"></a> [easy\_ec2](#module\_easy\_ec2) | ../../../modules/simple/ec2 | n/a |
| <a name="module_ec2_security_group"></a> [ec2\_security\_group](#module\_ec2\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
22 changes: 10 additions & 12 deletions examples/easy/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ locals {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -29,7 +29,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = var.enable_ipv6
assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand All @@ -55,19 +54,18 @@ module "ec2_security_group" {

module "asg" {
source = "terraform-aws-modules/autoscaling/aws"
version = "~> 4.0"
version = "~> 7.0"

name = "${local.prefix}-asg"

image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ec2_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 2
desired_capacity = 1
health_check_type = "EC2"
associate_public_ip_address = true
image_id = data.aws_ssm_parameter.ami_image.value
instance_type = "t2.micro"
security_groups = [module.ec2_security_group.security_group_id]
vpc_zone_identifier = module.vpc.public_subnets
min_size = 1
max_size = 2
desired_capacity = 1
health_check_type = "EC2"
user_data = templatefile("../../templates/ec2_userdata.tpl", {
ecs_cluster = module.ecs_cluster.name
})
Expand Down
2 changes: 1 addition & 1 deletion examples/easy/ec2/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
4 changes: 2 additions & 2 deletions examples/easy/fargate-alb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -49,7 +49,7 @@ $ terraform apply
| <a name="module_easy_fargate"></a> [easy\_fargate](#module\_easy\_fargate) | ../../../modules/simple/fargate | n/a |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a |
| <a name="module_task_security_group"></a> [task\_security\_group](#module\_task\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
3 changes: 1 addition & 2 deletions examples/easy/fargate-alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ locals {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -25,7 +25,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = var.enable_ipv6
assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand Down
2 changes: 1 addition & 1 deletion examples/easy/fargate-alb/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
4 changes: 2 additions & 2 deletions examples/easy/fargate-spot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -52,7 +52,7 @@ $ terraform apply
| <a name="module_easy_fargate"></a> [easy\_fargate](#module\_easy\_fargate) | ../../../modules/simple/fargate-spot | n/a |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a |
| <a name="module_task_security_group"></a> [task\_security\_group](#module\_task\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
3 changes: 1 addition & 2 deletions examples/easy/fargate-spot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -24,7 +24,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = true
assign_ipv6_address_on_creation = true
public_subnet_assign_ipv6_address_on_creation = true
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand Down
2 changes: 1 addition & 1 deletion examples/easy/fargate-spot/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
4 changes: 2 additions & 2 deletions examples/easy/fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ terraform apply

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.74.0 |

## Providers
Expand All @@ -45,7 +45,7 @@ $ terraform apply
| <a name="module_easy_fargate"></a> [easy\_fargate](#module\_easy\_fargate) | ../../../modules/simple/fargate | n/a |
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a |
| <a name="module_task_security_group"></a> [task\_security\_group](#module\_task\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

Expand Down
3 changes: 1 addition & 2 deletions examples/easy/fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ locals {

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.0"
version = "~> 5.0"

name = "${local.prefix}-vpc"
cidr = local.vpc_cidr
Expand All @@ -24,7 +24,6 @@ module "vpc" {
dhcp_options_domain_name_servers = ["AmazonProvidedDNS"]

enable_ipv6 = true
assign_ipv6_address_on_creation = true
public_subnet_assign_ipv6_address_on_creation = true
public_subnet_ipv6_prefixes = range(length(local.vpc_azs))
}
Expand Down
2 changes: 1 addition & 1 deletion examples/easy/fargate/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.1"
required_version = ">= 1.0"

required_providers {
aws = {
Expand Down
Loading

0 comments on commit 1e42d45

Please sign in to comment.