Skip to content

infraspecdev/terraform-aws-ecs

Repository files navigation

terraform-aws-ecs

A Terraform module to create ECS Cluster that relies on self-managed EC2 instances.

Architecture Diagram

ECS Architecture Diagram

Requirements

Name Version
terraform >= 1.8.4
aws >= 5.51.0

Providers

No providers.

Modules

Name Source Version
asg ./modules/asg n/a
cluster ./modules/cluster n/a

Resources

No resources.

Inputs

Name Description Type Default Required
asg_create_launch_template Either to create a Launch Template to associate with the Autoscaling group bool true no
asg_desired_capacity The number of Amazon EC2 instances that should be running in the group. number n/a yes
asg_health_check_type (Optional) "EC2" or "ELB". Controls how health checking is done. string "EC2" no
asg_iam_instance_profile_name (Optional, Forces new resource) Name of the instance profile. string null no
asg_iam_instance_profile_tags (Optional) Map of resource tags for the IAM Instance Profile. map(string) {} no
asg_iam_role_name (Optional, Forces new resource) Friendly name of the role. string null no
asg_iam_role_policy_attachments (Optional) - The ARNs of the policies you want to apply list(string)
[
"arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
]
no
asg_iam_role_tags Key-value mapping of tags for the IAM role. map(string) {} no
asg_instances_tags Resources Tags to propagate to the Instances map(string) {} no
asg_launch_template Launch Template to use with the Autoscaling group
object({
name = optional(string, null)
block_device_mappings = optional(list(object({
device_name = string
ebs = optional(object({
delete_on_termination = optional(bool, null)
snapshot_id = optional(string, null)
volume_size = optional(number, null)
volume_type = optional(string, null)
}))
no_device = optional(any, null)
virtual_name = optional(string, null)
})), [])
image_id = optional(string, null)
instance_type = optional(string, null)
vpc_security_group_ids = optional(list(string), [])
key_name = optional(string, null)
user_data = optional(string, null)
tags = optional(map(string), {})
})
{} no
asg_launch_template_id Identifier of the Launch Template string null no
asg_launch_template_version (Optional) Template version. string "$Default" no
asg_max_size Maximum size of the Auto Scaling Group number n/a yes
asg_min_size Minimum size of the Auto Scaling Group number n/a yes
asg_name (Optional) Name of the Auto Scaling Group. string null no
asg_protect_from_scale_in (Optional) Whether newly launched instances are automatically protected from termination by Amazon EC2 Auto Scaling when scaling in. bool false no
asg_tags Resources Tags for Autoscaling group map(string) {} no
asg_vpc_zone_identifier (Optional) List of subnet IDs to launch resources in. list(string) [] no
cluster_name (Required) Name of the cluster string n/a yes
cluster_service_connect_namespace (Optional) ARN of the aws_service_discovery_http_namespace that's used when you create a service and don't specify a Service Connect configuration. string null no
cluster_setting (Optional) Configuration block(s) with cluster settings.
list(object({
name = string
value = string
}))
[] no
cluster_tags (Optional) Key-value map of resource tags. map(string) {} no

Outputs

Name Description
asg_arn ARN for this Auto Scaling Group.
asg_iam_instance_profile_arn ARN assigned by AWS to the instance profile.
asg_iam_instance_profile_id Instance profile's ID.
asg_iam_role_id Name of the role.
asg_id Auto Scaling Group id.
asg_launch_template_arn Amazon Resource Name (ARN) of the launch template.
asg_launch_template_id The ID of the launch template.
cluster_arn ARN that identifies the cluster.
cluster_id Identifier of the ECS Cluster
cluster_name Name of the ECS Cluster