Skip to content

flightlesstux/aws-ecs-nginx-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

What this terraform can do?

  • 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

Requirements

  • 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.

Usage

  • 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.

Providers

Name Version
aws n/a
template n/a

Resources

Name Type
aws_alb.main resource
aws_alb_listener.front_end resource
aws_alb_target_group.nginx_app resource
aws_ecs_cluster.aws-ecs resource
aws_ecs_service.nginx_app resource
aws_ecs_task_definition.nginx_app resource
aws_iam_instance_profile.ecs-cluster-runner-profile resource
aws_iam_instance_profile.ecsInstanceRole resource
aws_iam_role.ecs-cluster-runner-role resource
aws_iam_role.ecsInstanceRole resource
aws_iam_role.ecsTaskExecutionRole resource
aws_iam_role_policy.ecs-cluster-runner-role-policy resource
aws_iam_role_policy_attachment.ecsInstanceRole resource
aws_iam_role_policy_attachment.ecsTaskExecutionRole resource
aws_instance.ecs-cluster-runner resource
aws_internet_gateway.aws-igw resource
aws_main_route_table_association.aws-route-table-association resource
aws_route_table.aws-route-table resource
aws_security_group.aws-ecs-tasks resource
aws_security_group.aws-lb resource
aws_security_group.ecs-cluster-host resource
aws_security_group_rule.ecs-cluster-egress resource
aws_security_group_rule.ecs-cluster-host-ssh resource
aws_subnet.aws-subnet resource
aws_vpc.aws-vpc resource
aws_ami.ecs-ami data source
aws_availability_zones.aws-az data source
aws_caller_identity.current data source
aws_iam_policy_document.ecs-cluster-runner-policy data source
aws_iam_policy_document.instance-assume-role data source
aws_iam_policy_document.task-assume-role data source
template_file.nginx_app data source
template_file.user_data_cluster data source

Inputs

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

Outputs

Name Description
ecs_cluster_runner_ip External IP of ECS Cluster
nginx_dns_lb DNS load balancer

Note

  • 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.

About

This project run ECS infrastructure in AWS Cloud

Resources

Stars

Watchers

Forks

Packages

No packages published