- Creating a VPC and other network things such as Route Table
- Creating a 2 different subnets (for HA)
- Creating a Load Balancer
- Creating a Security Group of Load Balancer
- Creating a Target Group for Load Balancer
- Creating a ec2 for ECS Runner
- Creating a Security Group for ECS Runner
- Creating an IAM Policies
- Creating a ECS Service
- Creating a ECS Cluster
- Creating a Security Group for ECS Cluster
- Before you start, you should know your AWS region. For example; eu-west-1 for Ireland region.
- Your Key Pair should previously generated on AWS side and you shold know the name.
- Export your AWS Access Key ID and Secret Access Key for create a resource in your AWS Region. Or if you want to use with Gitlab pipeline, just add these variables to your project settings.
AWS_ACCESS_KEY_ID=AKIA1SFAESADASFASR5D
AWS_SECRET_ACCESS_KEY=Aasdfiajfar1O9DFASDAA3rasdas02304adsq9re
- Clone this repository with
git clone [email protected]:flightlesstux/aws-ecs-nginx-app.git
cd aws-ecs-nginx-app/ireland/
terraform init
For make sure about terraform modules.terraform plan
to see how your environment looks like before deploy.terraform apply
to make a deploy.
Name | Version |
---|---|
aws | n/a |
template | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
admin_sources_cidr | List of IPv4 CIDR blocks from which to allow admin access | list(string) |
n/a | yes |
app_environment | Application environment | string |
n/a | yes |
app_name | Application name | string |
n/a | yes |
app_sources_cidr | List of IPv4 CIDR blocks from which to allow application access | list(string) |
n/a | yes |
aws_ecs_ami_override | Machine image to use for ec2 instances | string |
"" |
no |
aws_key_pair_name | AWS key pair name | string |
n/a | yes |
aws_region | AWS region | string |
n/a | yes |
cluster_runner_count | Number of EC2 instances for ECS Cluster Runner | string |
"1" |
no |
cluster_runner_type | EC2 instance type of ECS Cluster Runner | string |
"t3.medium" |
no |
nginx_app_count | Number of Docker containers to run | number |
2 |
no |
nginx_app_image | Docker image to run in the ECS cluster | any |
n/a | yes |
nginx_app_name | Name of Application Container | string |
"nginx" |
no |
nginx_app_port | Port exposed by the Docker image to redirect traffic to | number |
80 |
no |
nginx_fargate_cpu | Fargate instance CPU units to provision (1 vCPU = 1024 CPU units) | string |
"1024" |
no |
nginx_fargate_memory | Fargate instance memory to provision (in MiB) | string |
"2048" |
no |
Name | Description |
---|---|
ecs_cluster_runner_ip | External IP of ECS Cluster |
nginx_dns_lb | DNS load balancer |
- You can't run this terraform on ARM based CPUs such as AWS Gravition Family and/or Apple M1. The main reason is terraform template module v2.2.0 doesn't have ARM based cpu support. If you will try, you should get an error like below:
│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.
- I didn't lock the provider and modules version for this project. This terraform is not using in production but if you are planning to use in production, you should lock the providers and modules versions.