Skip to content

Files

Latest commit

 

History

History

complete

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

ECS Complete

Configuration in this directory creates:

  • ECS Cluster using self-managed EC2
  • Autoscaling Group with self-managed EC2 for the created ECS Cluster

Example tfvars file

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"
}

Usage

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.

Requirements

Name Version
terraform >= 1.8.4
aws >= 5.51.0

Providers

No providers.

Modules

Name Source Version
ecs ../../ n/a

Resources

No resources.

Inputs

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({
image_id = string
instance_type = string
key_name = string
security_group_ids = list(string)
})
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({
name = string
value = string
}))
n/a yes
cluster_tags A map of tags to assign to the cluster. map(string) n/a yes

Outputs

Name Description
cluster_arn ARN that identifies the cluster.
cluster_name Name of the ECS Cluster