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.
To configure your AWS profile for using this Terraform script, you have two options:
-
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.
-
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.
- 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.
terraform init
terraform plan
terraform validate && terraform apply
terraform destroy