NyiNyiSoePaing / terraform-ecs

Terraform template to Setup ECS Architecture with multiple capacity providers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Script to Setup ECS with multiple capacity providers

Logo

the architectural details that Terraform will provision!

Table of Contents

  1. Introduction

  2. Deployment

Introduction

Many open-source repositories support Terraform for setting up ECS (Elastic Container Service) with a single capacity provider, such as Fargate or EC2.

Therefore, I've crafted Terraform configurations within this repository to support multiple capacity providers, including EC2 autoscaling capacity provider, Fargate capacity provider, and Fargate spot capacity provider.

Deployment

Setting AWS Profile

To configure your AWS profile for using this Terraform script, you have two options:

  1. Export AWS Profile (Recommended):

    Execute the following command in your terminal to export the AWS profile:

    export AWS_DEFAULT_PROFILE=nyinyisoepaing

💡 Tip: Replace nyinyisoepaing with your AWS profile name.

  1. Set AWS Profile in var.tf and provider.tf Files

    Alternatively, you can set the AWS profile directly within the var.tf and provider.tf file.

    • Update the aws_credentials variable with your AWS access key and secret key:
    # variable.tf
     variable "aws_credentials" {
       type = object({
         access_key = string
         secret_key = string
       })
    
       default = {
         access_key = "your_access_key"
         secret_key = "your_secret_key"
       }
     }
    
    # provider.tf
    provider "aws" {
         region = var.aws_region
         access_key = var.access_key
         secret_key = var.secret_key
     }
    

💡 Tip: Replace "your_access_key" and "your_secret_key" with your AWS access key and secret key respectively.

⚠️ Warning: Make sure that the AWS profile you use has the necessary permissions to create and manage ECS resources.

Infra Provisioning

Update Variables:

  • Before initiating the deployment process, ensure that all variables in your var.tf file are updated with the appropriate values.
  • This includes variables such as AWS credentials, region, and any other parameters needed for your infrastructure.

Initialize Terraform:

terraform init

Generate Execution Plan:

terraform plan

Validation and Apply Changes:

terraform validate && terraform apply

CleanUp:

terraform destroy

About

Terraform template to Setup ECS Architecture with multiple capacity providers


Languages

Language:HCL 100.0%