Configuration in this directory creates:
- ECS Cluster using self-managed EC2
- Autoscaling Group with self-managed EC2 for the created ECS Cluster
cluster_name = "your-cluster-name"
cluster_setting = [
{
name = "containerInsights"
value = "enabled"
}
]
cluster_tags = {
ManagedBy = "Terraform"
Owner = "owner-name"
}
asg_name = "your-asg-name"
asg_vpc_zone_identifier = ["subnet-0123456789abcdefg", "subnet-0123456789abcdefg"]
asg_desired_capacity = 1
asg_min_size = 1
asg_max_size = 1
asg_instances_tags = {
ManagedBy = "Terraform"
Owner = "owner-name"
}
asg_tags = {
ManagedBy = "Terraform"
Owner = "owner-name"
}
# Launch Template
asg_create_launch_template = true
asg_launch_template = {
image_id = "ami-0123456789abcdefg"
instance_type = "your-instance-type"
key_name = "your-key-name"
security_group_ids = ["sg-0f1234567890abcdef"]
}
asg_launch_template_version = "your-launch-template-version"
# Launch Template IAM Role
asg_iam_role_name = "your-iam-role-name"
asg_iam_role_tags = {
ManagedBy = "Terraform"
Owner = "owner-name"
}
# Launch Template IAM Instance Profile
asg_iam_instance_profile_name = "your-iam-instance-profile-name"
asg_iam_instance_profile_tags = {
ManagedBy = "Terraform"
Owner = "owner-name"
}
To run this example, you will need to execute the commands:
terraform init
terraform plan
terraform apply
Please note that this example may create resources that can incur monetary charges on your AWS bill. You can run terraform destroy
when you no longer need the resources.
Name | Version |
---|---|
terraform | >= 1.8.4 |
aws | >= 5.51.0 |
No providers.
Name | Source | Version |
---|---|---|
ecs | ../../ | n/a |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
asg_create_launch_template | Whether to create a launch template. | bool |
n/a | yes |
asg_desired_capacity | The number of Amazon EC2 instances that should be running in the Auto Scaling Group. | number |
n/a | yes |
asg_iam_instance_profile_name | The name of the IAM instance profile for the Auto Scaling Group. | string |
n/a | yes |
asg_iam_instance_profile_tags | A map of tags to assign to the IAM instance profile. | map(string) |
n/a | yes |
asg_iam_role_name | The name of the IAM role for the Auto Scaling Group. | string |
n/a | yes |
asg_iam_role_tags | A map of tags to assign to the IAM role. | map(string) |
n/a | yes |
asg_instances_tags | A map of tags to assign to the instances within the Auto Scaling Group. | map(string) |
n/a | yes |
asg_launch_template | The configuration of the launch template. | object({ |
n/a | yes |
asg_launch_template_version | The version of the launch template to use. | string |
n/a | yes |
asg_max_size | The maximum size of the Auto Scaling Group. | number |
n/a | yes |
asg_min_size | The minimum size of the Auto Scaling Group. | number |
n/a | yes |
asg_name | The name of the Auto Scaling Group. | string |
n/a | yes |
asg_tags | A map of tags to assign to the Auto Scaling Group. | map(string) |
n/a | yes |
asg_vpc_zone_identifier | A list of subnet IDs to launch resources in. | list(string) |
n/a | yes |
cluster_name | The name of the ECS cluster. | string |
n/a | yes |
cluster_setting | The settings to use when creating the cluster. | list(object({ |
n/a | yes |
cluster_tags | A map of tags to assign to the cluster. | map(string) |
n/a | yes |
Name | Description |
---|---|
cluster_arn | ARN that identifies the cluster. |
cluster_name | Name of the ECS Cluster |