terraform-aws-modules
terraform-aws-ecs
HCL

Terraform module to create AWS ECS resources 🇺🇦

Last updated Jul 8, 2026
674
Stars
664
Forks
4
Issues
+1
Stars/day
Attention Score
91
Language breakdown
HCL 100.0%
Files click to expand
README

AWS ECS Terraform module

Terraform module which creates ECS (Elastic Container Service) resources on AWS.

SWUbanner

Available Features

  • ECS cluster w/ Fargate or EC2 Auto Scaling capacity providers
  • ECS Service w/ task definition, task set, and container definition support
  • Separate sub-modules or integrated module for ECS cluster and service
For more details see the design doc

Usage

This project supports creating resources through individual sub-modules, or through a single module that creates both the cluster and service resources. See the respective sub-module directory for more details and example usage.

Integrated Cluster w/ Services

module "ecs" {
  source = "terraform-aws-modules/ecs/aws"

cluster_name = "ecs-integrated"

cluster_configuration = { executecommandconfiguration = { logging = "OVERRIDE" log_configuration = { cloudwatchloggroupname = "/aws/ecs/aws-ec2" } } }

# Cluster capacity providers clustercapacityproviders = ["FARGATE", "FARGATE_SPOT"] defaultcapacityprovider_strategy = { FARGATE = { weight = 50 base = 20 } FARGATE_SPOT = { weight = 50 } }

services = { ecsdemo-frontend = { cpu = 1024 memory = 4096

# Container definition(s) container_definitions = {

fluent-bit = { cpu = 512 memory = 1024 essential = true image = "906394416424.dkr.ecr.us-west-2.amazonaws.com/aws-for-fluent-bit:stable" firelensConfiguration = { type = "fluentbit" } memoryReservation = 50 }

ecs-sample = { cpu = 512 memory = 1024 essential = true image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50" portMappings = [ { name = "ecs-sample" containerPort = 80 protocol = "tcp" } ]

# Example image used requires access to write to root filesystem readonlyRootFilesystem = false

dependsOn = [{ containerName = "fluent-bit" condition = "START" }]

enablecloudwatchlogging = false logConfiguration = { logDriver = "awsfirelens" options = { Name = "firehose" region = "eu-west-1" delivery_stream = "my-stream" log-driver-buffer-limit = "2097152" } } memoryReservation = 100 } }

serviceconnectconfiguration = { namespace = "example" service = [{ client_alias = { port = 80 dns_name = "ecs-sample" } port_name = "ecs-sample" discovery_name = "ecs-sample" }] }

load_balancer = { service = { targetgrouparn = "arn:aws:elasticloadbalancing:eu-west-1:1234567890:targetgroup/bluegreentarget1/209a844cd01825a4" container_name = "ecs-sample" container_port = 80 } }

subnet_ids = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]

securitygroupingress_rules = { alb_3000 = { description = "Service port" fromport = local.containerport ip_protocol = "tcp" referencedsecuritygroup_id = "sg-12345678" } } securitygroupegress_rules = { all = { ip_protocol = "-1" cidr_ipv4 = "0.0.0.0/0" } } } }

tags = { Environment = "Development" Project = "Example" } }

Examples

Requirements

| Name | Version | |------|---------| | terraform | >= 1.5.7 | | aws | >= 6.34 |

Providers

No providers.

Modules

| Name | Source | Version | |------|--------|---------| | cluster | ./modules/cluster | n/a | | service | ./modules/service | n/a |

Resources

No resources.

Inputs

| Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | capacity\providers | Map of capacity provider definitions to create for the cluster |

map(object({
auto
scalinggroupprovider = optional(object({
autoscalinggrouparn = string
managed
draining = optional(string, "ENABLED")
managedscaling = optional(object({
instance
warmupperiod = optional(number)
maximum
scalingstepsize = optional(number)
minimumscalingstepsize = optional(number)
status = optional(string)
target
capacity = optional(number)
}))
managedterminationprotection = optional(string)
}))
managedinstancesprovider = optional(object({
infrastructurerolearn = optional(string)
instancelaunchtemplate = object({
capacityoptiontype = optional(string)
ec2instanceprofilearn = optional(string)
instance
requirements = optional(object({
acceleratorcount = optional(object({
max = optional(number)
min = optional(number)
}))
accelerator
manufacturers = optional(list(string))
acceleratornames = optional(list(string))
accelerator
totalmemorymib = optional(object({
max = optional(number)
min = optional(number)
}))
acceleratortypes = optional(list(string))
allowed
instancetypes = optional(list(string))
bare
metal = optional(string)
baselineebsbandwidthmbps = optional(object({
max = optional(number)
min = optional(number)
}))
burstable
performance = optional(string)
cpumanufacturers = optional(list(string))
excluded
instancetypes = optional(list(string))
instance
generations = optional(list(string))
localstorage = optional(string)
local
storagetypes = optional(list(string))
max
spotpriceaspercentageofoptimalondemandprice = optional(number)
memorygibpervcpu = optional(object({
max = optional(number)
min = optional(number)
}))
memory
mib = optional(object({
max = optional(number)
min = optional(number)
}))
networkbandwidthgbps = optional(object({
max = optional(number)
min = optional(number)
}))
networkinterfacecount = optional(object({
max = optional(number)
min = optional(number)
}))
ondemandmaxpricepercentageoverlowestprice = optional(number)
require
hibernatesupport = optional(bool)
spot
maxpricepercentageoverlowestprice = optional(number)
total
localstoragegb = optional(object({
max = optional(number)
min = optional(number)
}))
vcpucount = optional(object({
max = optional(number)
min = optional(number)
}))
}))
monitoring = optional(string)
network
configuration = optional(object({
securitygroups = optional(list(string), [])
subnets = list(string)
}))
storage
configuration = optional(object({
storagesizegib = number
}))
})
propagatetags = optional(string, "CAPACITYPROVIDER")
}))
name = optional(string) # Will fall back to use map key if not set
tags = optional(map(string), {})
}))
| null | no | | cloudwatch\log\group\class | Specified the log class of the log group. Possible values are: STANDARD or INFREQUENTACCESS | string | null | no | | cloudwatch\log\group\kms\key\_id | If a KMS Key ARN is set, this key will be used to encrypt the corresponding log group. Please be sure that the KMS Key has an appropriate key policy (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html) | string | null | no | | cloudwatch\log\group\_name | Custom name of CloudWatch Log Group for ECS cluster | string | null | no | | cloudwatch\log\group\retention\in\_days | Number of days to retain log events | number | 90 | no | | cloudwatch\log\group\_tags | A map of additional tags to add to the log group created | map(string) | {} | no | | cluster\capacity\providers | List of capacity provider names to associate with the ECS cluster. Note: any capacity providers created by this module will be automatically added | list(string) | [] | no | | cluster\configuration | The execute command configuration for the cluster |
object({
execute
commandconfiguration = optional(object({
kms
keyid = optional(string)
log
configuration = optional(object({
cloudwatchencryptionenabled = optional(bool)
cloud
watchloggroupname = optional(string)
s3
bucketencryptionenabled = optional(bool)
s3bucketname = optional(string)
s3kmskeyid = optional(string)
s3
keyprefix = optional(string)
}))
logging = optional(string, "OVERRIDE")
}))
managed
storageconfiguration = optional(object({
fargate
ephemeralstoragekmskeyid = optional(string)
kmskeyid = optional(string)
}))
})
|
{
"executecommandconfiguration": {
"logconfiguration": {
"cloud
watchloggroup_name": "placeholder"
}
}
}
| no | | cluster\_name | Name of the cluster (up to 255 letters, numbers, hyphens, and underscores) | string | "" | no | | cluster\service\connect\_defaults | Configures a default Service Connect namespace |
object({
namespace = string
})
| null | no | | cluster\_setting | List of configuration block(s) with cluster settings. For example, this can be used to enable CloudWatch Container Insights for a cluster |
list(object({
name = string
value = string
}))
|
[
{
"name": "containerInsights",
"value": "enabled"
}
]
| no | | cluster\_tags | A map of additional tags to add to the cluster | map(string) | {} | no | | create | Determines whether resources will be created (affects all resources) | bool | true | no | | create\cloudwatch\log\_group | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | bool | true | no | | create\infrastructure\iam\_role | Determines whether the ECS infrastructure IAM role should be created | bool | true | no | | create\node\iam\instance\profile | Determines whether an IAM instance profile is created or to use an existing IAM instance profile | bool | true | no | | create\security\group | Determines if a security group is created | bool | true | no | | create\task\exec\iam\role | Determines whether the ECS task definition IAM role should be created | bool | false | no | | create\task\exec\_policy | Determines whether the ECS task definition IAM policy should be created. This includes permissions included in AmazonECSTaskExecutionRolePolicy as well as access to secrets and SSM parameters | bool | true | no | | default\capacity\provider\_strategy | Map of default capacity provider strategy definitions to use for the cluster |
map(object({
base = optional(number)
name = optional(string) # Will fall back to use map key if not set
weight = optional(number)
}))
| null | no | | disable\v7\default\name\description | [DEPRECATED - will be removed in v8.0] Determines whether to disable the default postfix added to resource names and descriptions added in v7.0 | bool | false | no | | infrastructure\iam\role\_description | Description of the role | string | null | no | | infrastructure\iam\role\_name | Name to use on IAM role created | string | null | no | | infrastructure\iam\role\override\policy\_documents | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank sids will override statements with the same sid | list(string) | [] | no | | infrastructure\iam\role\_path | IAM role path | string | null | no | | infrastructure\iam\role\permissions\boundary | ARN of the policy that is used to set the permissions boundary for the IAM role | string | null | no | | infrastructure\iam\role\source\policy\_documents | List of IAM policy documents that are merged together into the exported document. Statements must have unique sids | list(string) | [] | no | | infrastructure\iam\role\statements | A map of IAM policy statements for custom permission usage |
map(object({
sid = optional(string)
actions = optional(list(string))
notactions = optional(list(string))
effect = optional(string, "Allow")
resources = optional(list(string))
not
resources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
not_principals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
variable = string
values = list(string)
})))
}))
| null | no | | infrastructure\iam\role\_tags | A map of additional tags to add to the IAM role created | map(string) | {} | no | | infrastructure\iam\role\use\name\prefix | Determines whether the IAM role name (iamrole_name) is used as a prefix | bool | true | no | | node\iam\role\additional\policies | Additional policies to be added to the IAM role | map(string) | {} | no | | node\iam\role\_description | Description of the role | string | "ECS Managed Instances node IAM role" | no | | node\iam\role\_name | Name to use on IAM role/instance profile created | string | null | no | | node\iam\role\override\policy\_documents | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank sids will override statements with the same sid | list(string) | [] | no | | node\iam\role\_path | IAM role/instance profile path | string | null | no | | node\iam\role\permissions\boundary | ARN of the policy that is used to set the permissions boundary for the IAM role | string | null | no | | node\iam\role\source\policy\_documents | List of IAM policy documents that are merged together into the exported document. Statements must have unique sids | list(string) | [] | no | | node\iam\role\statements | A map of IAM policy statements for custom permission usage |
map(object({
sid = optional(string)
actions = optional(list(string))
notactions = optional(list(string))
effect = optional(string, "Allow")
resources = optional(list(string))
not
resources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
not_principals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
variable = string
values = list(string)
})))
}))
| null | no | | node\iam\role\_tags | A map of additional tags to add to the IAM role/instance profile created | map(string) | {} | no | | node\iam\role\use\name\prefix | Determines whether the IAM role/instance profile name (nodeiamrolename) is used as a prefix | bool | true | no | | region | Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration | string | null | no | | security\group\description | Description of the security group created | string | null | no | | security\group\egress\rules | Security group egress rules to add to the security group created |
map(object({
name = optional(string)

cidr
ipv4 = optional(string)
cidripv6 = optional(string)
description = optional(string)
from
port = optional(string)
ipprotocol = optional(string, "tcp")
prefix
listid = optional(string)
referenced
securitygroupid = optional(string)
tags = optional(map(string), {})
toport = optional(string)
}))
|
{
"all
ipv4": {
"cidripv4": "0.0.0.0/0",
"description": "Allow all IPv4 traffic",
"ip
protocol": "-1"
},
"allipv6": {
"cidr
ipv6": "::/0",
"description": "Allow all IPv6 traffic",
"ip_protocol": "-1"
}
}
| no | | security\group\ingress\rules | Security group ingress rules to add to the security group created |
map(object({
name = optional(string)

cidr
ipv4 = optional(string)
cidripv6 = optional(string)
description = optional(string)
from
port = optional(string)
ipprotocol = optional(string, "tcp")
prefix
listid = optional(string)
referenced
securitygroupid = optional(string)
tags = optional(map(string), {})
to_port = optional(string)
}))
| {} | no | | security\group\name | Name to use on security group created | string | null | no | | security\group\tags | A map of additional tags to add to the security group created | map(string) | {} | no | | security\group\use\name\prefix | Determines whether the security group name (securitygroupname) is used as a prefix | bool | true | no | | services | Map of service definitions to create |
map(object({
create = optional(bool)
createservice = optional(bool)
tags = optional(map(string))

# Service
ignore
taskdefinitionchanges = optional(bool)
alarms = optional(object({
alarmnames = list(string)
enable = optional(bool)
rollback = optional(bool)
}))
availability
zonerebalancing = optional(string)
capacity
providerstrategy = optional(map(object({
base = optional(number)
capacity
provider = string
weight = optional(number)
})))
deploymentcircuitbreaker = optional(object({
enable = bool
rollback = bool
}))
deploymentconfiguration = optional(object({
strategy = optional(string)
bake
timeinminutes = optional(string)
canaryconfiguration = optional(object({
canary
baketimeinminutes = optional(string)
canary
percent = optional(string)
}))
linearconfiguration = optional(object({
step
baketimeinminutes = optional(string)
step
percent = optional(string)
}))
lifecyclehook = optional(map(object({
hook
targetarn = string
role
arn = optional(string)
lifecyclestages = list(string)
hook
details = optional(string)
})))
}))
deploymentcontroller = optional(object({
type = optional(string)
}))
deployment
maximumpercent = optional(number, 200)
deployment
minimumhealthypercent = optional(number, 66)
desiredcount = optional(number, 1)
enable
ecsmanagedtags = optional(bool)
enableexecutecommand = optional(bool)
forcedelete = optional(bool)
force
newdeployment = optional(bool)
health
checkgraceperiodseconds = optional(number)
launch
type = optional(string)
loadbalancer = optional(map(object({
container
name = string
containerport = number
elb
name = optional(string)
targetgrouparn = optional(string)
advancedconfiguration = optional(object({
alternate
targetgrouparn = string
productionlistenerrule = string # Should be optional but bug in provider
rolearn = optional(string)
test
listenerrule = optional(string)
}))
})))
name = optional(string) # Will fall back to use map key if not set
assign
publicip = optional(bool)
security
groupids = optional(list(string))
subnet
ids = optional(list(string))
orderedplacementstrategy = optional(list(object({
field = optional(string)
type = string
})))
placementconstraints = optional(map(object({
expression = optional(string)
type = string
})))
platform
version = optional(string)
propagatetags = optional(string)
scheduling
strategy = optional(string)
serviceconnectconfiguration = optional(object({
enabled = optional(bool)
accesslogconfiguration = optional(object({
format = string
includequeryparameters = optional(string)
}))
logconfiguration = optional(object({
log
driver = string
options = optional(map(string))
secretoption = optional(list(object({
name = string
value
from = string
})))
}))
namespace = optional(string)
service = optional(list(object({
clientalias = optional(object({
dns
name = optional(string)
port = number
testtrafficrules = optional(list(object({
header = optional(object({
name = string
value = object({
exact = string
})
}))
})))
}))
discoveryname = optional(string)
ingress
portoverride = optional(number)
port
name = string
timeout = optional(object({
idletimeoutseconds = optional(number)
perrequesttimeoutseconds = optional(number)
}))
tls = optional(object({
issuer
certauthority = object({
aws
pcaauthorityarn = string
})
kmskey = optional(string)
role
arn = optional(string)
}))
})))
}))
serviceregistries = optional(object({
container
name = optional(string)
containerport = optional(number)
port = optional(number)
registry
arn = string
}))
sigintrollback = optional(bool)
timeouts = optional(object({
create = optional(string)
update = optional(string)
delete = optional(string)
}))
triggers = optional(map(string))
volume
configuration = optional(object({
name = string
managedebsvolume = object({
encrypted = optional(bool)
filesystemtype = optional(string)
iops = optional(number)
kmskeyid = optional(string)
sizeingb = optional(number)
snapshotid = optional(string)
tag
specifications = optional(list(object({
propagatetags = optional(string)
resource
type = string
tags = optional(map(string))
})))
throughput = optional(number)
volumeinitializationrate = optional(number)
volumetype = optional(string)
})
}))
vpc
latticeconfigurations = optional(object({
role
arn = string
targetgrouparn = string
portname = string
}))
wait
forsteadystate = optional(bool)
servicetags = optional(map(string))
# Service - IAM Role
create
iamrole = optional(bool)
iam
rolearn = optional(string)
iam
rolename = optional(string)
iam
roleusenameprefix = optional(bool)
iam
rolepath = optional(string)
iam
roledescription = optional(string)
iam
rolepermissionsboundary = optional(string)
iamroletags = optional(map(string))
iamrolestatements = optional(list(object({
sid = optional(string)
actions = optional(list(string))
notactions = optional(list(string))
effect = optional(string)
resources = optional(list(string))
not
resources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
notprincipals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
values = list(string)
variable = string
})))
})))
# Task Definition
create
taskdefinition = optional(bool)
task
definitionarn = optional(string)
container
definitions = optional(map(object({
operatingsystemfamily = optional(string)
tags = optional(map(string))

# Container definition
command = optional(list(string))
cpu = optional(number)
credentialSpecs = optional(list(string))
dependsOn = optional(list(object({
condition = string
containerName = string
})))
disableNetworking = optional(bool)
dnsSearchDomains = optional(list(string))
dnsServers = optional(list(string))
dockerLabels = optional(map(string))
dockerSecurityOptions = optional(list(string))
enableexecutecommand = optional(bool)
entrypoint = optional(list(string))
environment = optional(list(object({
name = string
value = string
})))
environmentFiles = optional(list(object({
type = string
value = string
})))
essential = optional(bool)
extraHosts = optional(list(object({
hostname = string
ipAddress = string
})))
firelensConfiguration = optional(object({
options = optional(map(string))
type = optional(string)
}))
healthCheck = optional(object({
command = optional(list(string))
interval = optional(number)
retries = optional(number)
startPeriod = optional(number)
timeout = optional(number)
}))
hostname = optional(string)
image = optional(string)
interactive = optional(bool)
links = optional(list(string))
linuxParameters = optional(object({
capabilities = optional(object({
add = optional(list(string))
drop = optional(list(string))
}))
devices = optional(list(object({
containerPath = optional(string)
hostPath = optional(string)
permissions = optional(list(string))
})))
initProcessEnabled = optional(bool)
maxSwap = optional(number)
sharedMemorySize = optional(number)
swappiness = optional(number)
tmpfs = optional(list(object({
containerPath = string
mountOptions = optional(list(string))
size = number
})))
}))
logConfiguration = optional(object({
logDriver = optional(string)
options = optional(map(string))
secretOptions = optional(list(object({
name = string
valueFrom = string
})))
}))
memory = optional(number)
memoryReservation = optional(number)
mountPoints = optional(list(object({
containerPath = optional(string)
readOnly = optional(bool)
sourceVolume = optional(string)
})), [])
name = optional(string)
portMappings = optional(list(object({
appProtocol = optional(string)
containerPort = optional(number)
containerPortRange = optional(string)
hostPort = optional(number)
name = optional(string)
protocol = optional(string)
})), [])
privileged = optional(bool)
pseudoTerminal = optional(bool)
readonlyRootFilesystem = optional(bool)
repositoryCredentials = optional(object({
credentialsParameter = optional(string)
}))
resourceRequirements = optional(list(object({
type = string
value = string
})))
restartPolicy = optional(object({
enabled = optional(bool)
ignoredExitCodes = optional(list(number))
restartAttemptPeriod = optional(number)
}))
secrets = optional(list(object({
name = string
valueFrom = string
})))
startTimeout = optional(number)
stopTimeout = optional(number)
systemControls = optional(list(object({
namespace = optional(string)
value = optional(string)
})))
ulimits = optional(list(object({
hardLimit = number
name = string
softLimit = number
})))
user = optional(string)
versionConsistency = optional(string)
volumesFrom = optional(list(object({
readOnly = optional(bool)
sourceContainer = optional(string)
})))
workingDirectory = optional(string)

# Cloudwatch Log Group
service = optional(string, "")
enablecloudwatchlogging = optional(bool)
createcloudwatchloggroup = optional(bool)
cloudwatch
loggroupname = optional(string)
cloudwatchloggroupusenameprefix = optional(bool)
cloudwatch
loggroupclass = optional(string)
cloudwatchloggroupretentionindays = optional(number)
cloudwatch
loggroupkmskeyid = optional(string)
})))
cpu = optional(number, 1024)
enablefaultinjection = optional(bool)
ephemeralstorage = optional(object({
size
ingib = number
}))
family = optional(string)
ipc
mode = optional(string)
memory = optional(number, 2048)
networkmode = optional(string)
pid
mode = optional(string)
proxyconfiguration = optional(object({
container
name = string
properties = optional(map(string))
type = optional(string)
}))
requirescompatibilities = optional(list(string))
runtime
platform = optional(object({
cpuarchitecture = optional(string)
operating
systemfamily = optional(string)
}))
skip
destroy = optional(bool)
taskdefinitionplacementconstraints = optional(map(object({
expression = optional(string)
type = string
})))
track
latest = optional(bool)
volume = optional(map(object({
configureatlaunch = optional(bool)
dockervolumeconfiguration = optional(object({
autoprovision = optional(bool)
driver = optional(string)
driveropts = optional(map(string))
labels = optional(map(string))
scope = optional(string)
}))
efs
volumeconfiguration = optional(object({
authorization
config = optional(object({
accesspointid = optional(string)
iam = optional(string)
}))
filesystemid = string
rootdirectory = optional(string)
transit
encryption = optional(string)
transitencryptionport = optional(number)
}))
fsxwindowsfileservervolumeconfiguration = optional(object({
authorization
config = optional(object({
credentialsparameter = string
domain = string
}))
file
systemid = string
root
directory = string
}))
hostpath = optional(string)
name = optional(string)
})))
task
tags = optional(map(string))
# Task Execution - IAM Role
createtaskexeciamrole = optional(bool)
taskexeciamrolearn = optional(string)
taskexeciamrolename = optional(string)
taskexeciamroleusenameprefix = optional(bool)
taskexeciamrolepath = optional(string)
taskexeciamroledescription = optional(string)
taskexeciamrolepermissionsboundary = optional(string)
task
execiamroletags = optional(map(string))
task
execiamrolepolicies = optional(map(string))
task
execiamrolemaxsessionduration = optional(number)
create
taskexecpolicy = optional(bool)
taskexecssmparamarns = optional(list(string))
taskexecsecretarns = optional(list(string))
task
execiamstatements = optional(list(object({
sid = optional(string)
actions = optional(list(string))
notactions = optional(list(string))
effect = optional(string)
resources = optional(list(string))
not
resources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
notprincipals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
values = list(string)
variable = string
})))
})))
task
execiampolicypath = optional(string)
# Tasks - IAM Role
create
tasksiamrole = optional(bool)
tasksiamrolearn = optional(string)
tasks
iamrolename = optional(string)
tasksiamroleusenameprefix = optional(bool)
tasks
iamrolepath = optional(string)
tasksiamroledescription = optional(string)
tasks
iamrolepermissionsboundary = optional(string)
tasks
iamroletags = optional(map(string))
tasksiamrolepolicies = optional(map(string))
tasks
iamrolemaxsessionduration = optional(number)
tasksiamrolestatements = optional(list(object({
sid = optional(string)
actions = optional(list(string))
not
actions = optional(list(string))
effect = optional(string)
resources = optional(list(string))
notresources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
not
principals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
values = list(string)
variable = string
})))
})))
# Task Set
externalid = optional(string)
scale = optional(object({
unit = optional(string)
value = optional(number)
}))
wait
untilstable = optional(bool)
wait
untilstabletimeout = optional(string)
# Autoscaling
enableautoscaling = optional(bool)
autoscaling
mincapacity = optional(number)
autoscaling
maxcapacity = optional(number)
autoscaling
policies = optional(map(object({
name = optional(string) # Will fall back to the key name if not provided
policytype = optional(string)
predictive
scalingpolicyconfiguration = optional(object({
maxcapacitybreachbehavior = optional(string)
max
capacitybuffer = optional(number)
metric
specification = list(object({
customizedcapacitymetricspecification = optional(object({
metric
dataquery = list(object({
expression = optional(string)
id = string
label = optional(string)
metric
stat = optional(object({
metric = object({
dimension = optional(list(object({
name = string
value = string
})))
metricname = optional(string)
namespace = optional(string)
})
stat = string
unit = optional(string)
}))
return
data = optional(bool)
}))
}))
customizedloadmetricspecification = optional(object({
metric
dataquery = list(object({
expression = optional(string)
id = string
label = optional(string)
metric
stat = optional(object({
metric = object({
dimension = optional(list(object({
name = string
value = string
})))
metricname = optional(string)
namespace = optional(string)
})
stat = string
unit = optional(string)
}))
return
data = optional(bool)
}))
}))
customizedscalingmetricspecification = optional(object({
metric
dataquery = list(object({
expression = optional(string)
id = string
label = optional(string)
metric
stat = optional(object({
metric = object({
dimension = optional(list(object({
name = string
value = string
})))
metricname = optional(string)
namespace = optional(string)
})
stat = string
unit = optional(string)
}))
return
data = optional(bool)
}))
}))
predefinedloadmetricspecification = optional(object({
predefined
metrictype = string
resource
label = optional(string)
}))
predefinedmetricpairspecification = optional(object({
predefined
metrictype = string
resource
label = optional(string)
}))
predefinedscalingmetricspecification = optional(object({
predefined
metrictype = string
resource
label = optional(string)
}))
targetvalue = number
}))
mode = optional(string)
scheduling
buffertime = optional(number)
}))
step
scalingpolicyconfiguration = optional(object({
adjustmenttype = optional(string)
cooldown = optional(number)
metric
aggregationtype = optional(string)
min
adjustmentmagnitude = optional(number)
step
adjustment = optional(list(object({
metricintervallowerbound = optional(string)
metric
intervalupperbound = optional(string)
scalingadjustment = number
})))
}))
target
trackingscalingpolicyconfiguration = optional(object({
customized
metricspecification = optional(object({
dimensions = optional(list(object({
name = string
value = string
})))
metric
name = optional(string)
metrics = optional(list(object({
expression = optional(string)
id = string
label = optional(string)
metricstat = optional(object({
metric = object({
dimensions = optional(list(object({
name = string
value = string
})))
metric
name = string
namespace = string
})
stat = string
unit = optional(string)
}))
returndata = optional(bool)
})))
namespace = optional(string)
statistic = optional(string)
unit = optional(string)
}))

disable
scalein = optional(bool)
predefined
metricspecification = optional(object({
predefined
metrictype = string
resource
label = optional(string)
}))
scaleincooldown = optional(number)
scaleoutcooldown = optional(number)
targetvalue = optional(number)
}))
})))
autoscaling
scheduledactions = optional(map(object({
name = optional(string)
min
capacity = number
maxcapacity = number
schedule = string
start
time = optional(string)
endtime = optional(string)
timezone = optional(string)
})))
autoscaling
suspendedstate = optional(object({
dynamic
scalinginsuspended = optional(bool)
dynamicscalingoutsuspended = optional(bool)
scheduled
scalingsuspended = optional(bool)
}))
# Security Group
create
securitygroup = optional(bool)
vpc
id = optional(string)
securitygroupname = optional(string)
securitygroupusenameprefix = optional(bool)
securitygroupdescription = optional(string)
securitygroupingressrules = optional(map(object({
cidr
ipv4 = optional(string)
cidripv6 = optional(string)
description = optional(string)
from
port = optional(string)
ipprotocol = optional(string)
prefix
listid = optional(string)
referenced
securitygroupid = optional(string)
tags = optional(map(string))
toport = optional(string)
})))
security
groupegressrules = optional(map(object({
cidripv4 = optional(string)
cidr
ipv6 = optional(string)
description = optional(string)
fromport = optional(string)
ip
protocol = optional(string)
prefixlistid = optional(string)
referencedsecuritygroupid = optional(string)
tags = optional(map(string))
to
port = optional(string)
})))
securitygrouptags = optional(map(string))
# ECS Infrastructure IAM Role
createinfrastructureiamrole = optional(bool)
infrastructure
iamrolearn = optional(string)
infrastructureiamrolename = optional(string)
infrastructure
iamroleusenameprefix = optional(bool)
infrastructureiamrolepath = optional(string)
infrastructure
iamroledescription = optional(string)
infrastructureiamrolepermissionsboundary = optional(string)
infrastructureiamrole_tags = optional(map(string))
}))
| null | no | | tags | A map of tags to add to all resources | map(string) | {} | no | | task\exec\iam\role\description | Description of the role | string | null | no | | task\exec\iam\role\name | Name to use on IAM role created | string | null | no | | task\exec\iam\role\path | IAM role path | string | null | no | | task\exec\iam\role\permissions\_boundary | ARN of the policy that is used to set the permissions boundary for the IAM role | string | null | no | | task\exec\iam\role\policies | Map of IAM role policy ARNs to attach to the IAM role | map(string) | {} | no | | task\exec\iam\role\tags | A map of additional tags to add to the IAM role created | map(string) | {} | no | | task\exec\iam\role\use\name\prefix | Determines whether the IAM role name (taskexeciamrolename) is used as a prefix | bool | true | no | | task\exec\iam\statements | A map of IAM policy statements for custom permission usage |
map(object({
sid = optional(string)
actions = optional(list(string))
notactions = optional(list(string))
effect = optional(string, "Allow")
resources = optional(list(string))
not
resources = optional(list(string))
principals = optional(list(object({
type = string
identifiers = list(string)
})))
not_principals = optional(list(object({
type = string
identifiers = list(string)
})))
condition = optional(list(object({
test = string
variable = string
values = list(string)
})))
}))
| null | no | | task\exec\secret\_arns | List of SecretsManager secret ARNs the task execution role will be permitted to get/read | list(string) | [] | no | | task\exec\ssm\param\arns | List of SSM parameter ARNs the task execution role will be permitted to get/read | list(string) | [] | no | | vpc\_id | The ID of the VPC where the security group will be created | string | null | no |

Outputs

| Name | Description | |------|-------------| | capacity\_providers | Map of autoscaling capacity providers created and their attributes | | cloudwatch\log\group\_arn | ARN of CloudWatch log group created | | cloudwatch\log\group\_name | Name of CloudWatch log group created | | cluster\_arn | ARN that identifies the cluster | | cluster\capacity\providers | Map of cluster capacity providers attributes | | cluster\_id | ID that identifies the cluster | | cluster\_name | Name that identifies the cluster | | infrastructure\iam\role\_arn | The Amazon Resource Name (ARN) specifying the IAM role | | infrastructure\iam\role\_name | IAM role name | | infrastructure\iam\role\unique\id | Stable and unique string identifying the IAM role | | node\iam\instance\profile\arn | ARN assigned by AWS to the instance profile | | node\iam\instance\profile\id | Instance profile's ID | | node\iam\instance\profile\unique | Stable and unique string identifying the IAM instance profile | | node\iam\role\_arn | The Amazon Resource Name (ARN) specifying the IAM role | | node\iam\role\_name | IAM role name | | node\iam\role\unique\id | Stable and unique string identifying the IAM role | | services | Map of services created and their attributes | | task\exec\iam\role\arn | Task execution IAM role ARN | | task\exec\iam\role\name | Task execution IAM role name | | task\exec\iam\role\unique\_id | Stable and unique string identifying the task execution IAM role |

Authors

Module is maintained by Anton Babenko with help from these awesome contributors.

License

Apache-2.0 Licensed. See LICENSE

🔗 More in this category

© 2026 GitRepoTrend · terraform-aws-modules/terraform-aws-ecs · Updated daily from GitHub