This folder contains the Terraform code to deploy the core infratructure for an ECS Fargate workload. The AWS resources created by the script are:
- Networking
- VPC
- 3 public subnets, 1 per AZ. If a region has less than 3 AZs it will create same number of public subnets as AZs.
- 3 private subnets, 1 per AZ. If a region has less than 3 AZs it will create same number of private subnets as AZs.
- 1 NAT Gateway
- 1 Internet Gateway
- Associated Route Tables
- VPC
- 1 ECS Cluster with AWS CloudWatch Container Insights enabled.
- Task execution IAM role
- CloudWatch log groups
- CloudMap service discovery namespace
default
Make sure you have all the prerequisites for your laptop.
- Clone the forked repository from your account (not the one from the aws-ia organization) and change the directory to the appropriate one as shown below:
cd ecs-blueprints/terraform/fargate-examples/core-infra/
- Run Terraform init to download the providers and install the modules
terraform init
- Review the terraform plan output, take a look at the changes that terraform will execute, and then apply them:
terraform plan
terraform apply --auto-approve
After the execution of the Terraform code you will get an output with needed IDs and values needed as input for the nexts Terraform applies. You can use this infrastructure to run other example blueprints, all you need is the cluster_name
.
Run the following command if you want to delete all the resources created before. If you have created other blueprints and they use these infrastructure then destroy those blueprint resources first.
terraform destroy
Name | Version |
---|---|
terraform | >= 1.1 |
aws | ~> 4.43 |
Name | Version |
---|---|
aws | ~> 4.43 |
Name | Source | Version |
---|---|---|
ecs | terraform-aws-modules/ecs/aws | ~> 5.0 |
vpc | terraform-aws-modules/vpc/aws | ~> 3.0 |
Name | Type |
---|---|
aws_service_discovery_private_dns_namespace.this | resource |
aws_availability_zones.available | data source |
aws_caller_identity.current | data source |
No inputs.
Name | Description |
---|---|
ecs_cluster_id | The ID of the ECS cluster |
ecs_cluster_name | The name of the ECS cluster and the name of the core stack |
ecs_task_execution_role_arn | The ARN of the task execution role |
ecs_task_execution_role_name | The ARN of the task execution role |
private_subnets | A list of private subnets for the client app |
private_subnets_cidr_blocks | A list of private subnets CIDRs |
public_subnets | A list of public subnets |
service_discovery_namespaces | Service discovery namespaces already available |
vpc_id | The ID of the VPC |