Skip to content

ecs-fargate-basic

Combines the vpc and ecs-fargate-service modules to run a container behind an ALB. Defaults to a public nginx placeholder image; push your image to the ecr_repository_url output and set container_image to deploy it.

Not zero cost: tasks run in private subnets, so the example creates a NAT gateway and an ALB (billed per hour). Requires AWS credentials; review with terraform plan before applying.

Requirements

Name Version
terraform >= 1.6.0
aws >= 5.0

Providers

No providers.

Modules

Name Source Version
service ../../modules/ecs-fargate-service n/a
vpc ../../modules/vpc n/a

Resources

No resources.

Inputs

Name Description Type Default Required
azs Exactly two availability zones in region to spread the subnets across. list(string)
[
"us-east-1a",
"us-east-1b"
]
no
certificate_arn Optional ACM certificate ARN. When set the ALB serves HTTPS and redirects HTTP to it. string null no
container_image Container image to run. Defaults to a public placeholder image; replace it with the image pushed to the ecr_repository_url output. string "public.ecr.aws/nginx/nginx:stable" no
container_port Port the container listens on. number 80 no
region AWS region to deploy the example into. string "us-east-1" no

Outputs

Name Description
alb_dns_name DNS name of the load balancer serving the example service.
cluster_name Name of the ECS cluster.
ecr_repository_url URL of the ECR repository to push the application image to.
service_name Name of the ECS service.