Skip to content

Terraform Apply

Before deploying, configure the Terraform variables in terraform.tfvars. The terraform-aws-ecs-express-mode-demo project exposes four input variables — all have defaults, so you only need to override values you want to change.

Create a terraform.tfvars file in the repository root:

terraform.tfvars
project = "ecs-express-mode-demo"
environment = "dev"
aws_region = "ap-southeast-2"
vpc_cidr = "10.42.0.0/16"
VariableTypeDescription
projectstring

Project name used for resource naming and tagging. Lowercase alphanumeric characters and hyphens only; 3–50 characters.

environmentstring

Deployment environment. Must be one of dev, staging, or prod.

aws_regionstring

AWS region for resource deployment. Must support your chosen Bedrock foundation model.

vpc_cidrstring

CIDR block for the VPC created by this project (for example, 10.42.0.0/16).

Run terraform init to download provider plugins and initialize the working directory. This step fetches the AWS provider and prepares the local state:

Terminal window
terraform init

You should see output confirming that providers were installed and Terraform is ready:

Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Installing hashicorp/aws...
Terraform has been successfully initialized!

With variables configured and providers initialized, run terraform apply to create all resources:

Terminal window
terraform apply

Terraform displays a plan showing the resources it will create. Review the plan and type yes to confirm. The Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs.
resource triggers Express Mode to provision its managed infrastructure alongside your declared resources.

When Terraform applies the Express Gateway Service
The aws_ecs_express_gateway_service Terraform resource that provisions an ECS service with managed ALB, auto scaling, and simplified configuration for HTTP/HTTPS web applications and APIs.
resource, ECS Express Mode automatically provisions several managed resources that you would otherwise configure manually with classic ECS:

ResourceWhat Express Mode Does
Shared ALB
The Application Load Balancer shared by up to 25 Express services in the same VPC using Host header routing rules.

Creates or reuses a shared ALB in the VPC with Host header routing rules. Up to 25 Express services share a single ALB.

Target group

Registers ECS tasks automatically and configures health checks using the health_check_path you specify.

Auto scaling

Configures target tracking scaling based on the auto_scaling_metric (CPU or memory), scaling between min_task_count and max_task_count.

DNS / Application URL
The unique Express-provisioned HTTPS URL on *.ecs.<region>.on.aws used for all normal application traffic.

Assigns a unique HTTPS endpoint on *.ecs.<region>.on.aws with a managed TLS certificate — no Route 53 or ACM configuration required.

RollbackAlarm
A CloudWatch metric alarm created by Express Mode that triggers automatic deployment rollback when new tasks fail ALB health checks.

Creates a CloudWatch alarm that triggers automatic deployment rollback when new tasks fail ALB health checks.

Once terraform apply finishes successfully, Terraform outputs the Application URL
The unique Express-provisioned HTTPS URL on *.ecs.<region>.on.aws used for all normal application traffic.
and other resource identifiers. The next step is verifying the service is healthy and accessible — covered on the Verifying page.

Terminal window
terraform output