https://github.com/ym1085/terraform-aws-ecs
IaC to configure the ECS infrastructure environment
https://github.com/ym1085/terraform-aws-ecs
aws terraform
Last synced: 2 months ago
JSON representation
IaC to configure the ECS infrastructure environment
- Host: GitHub
- URL: https://github.com/ym1085/terraform-aws-ecs
- Owner: ym1085
- Created: 2024-10-08T03:16:30.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-11-23T00:44:41.000Z (6 months ago)
- Last Synced: 2024-11-23T01:26:01.013Z (6 months ago)
- Topics: aws, terraform
- Language: HCL
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform ECS
## Package Structure
```shell
TERAFORM-AWS-ECS/
├── env/
│ ├── dev/
│ │ ├── .terraform.lock.hcl
│ │ ├── graph.dot
│ │ ├── alias.sh
│ │ ├── graph.sh
│ │ ├── main.tf
│ │ ├── provider.tf
│ │ ├── terraform.tfvars
│ │ └── variables.tf
│ │ └── backend.tf
│ ├── qa/
│ └── stg/
├── jenkins/
├── modules/
│ ├── alb/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── ecs/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── task_definitions_bak.tpl
│ │ ├── task_definitions.tpl
│ │ └── variables.tf
│ ├── gateway/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── route_tables/
│ │ ├── main.tf
│ │ └── variables.tf
│ ├── s3/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── security_groups/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── subnets/
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── vpc/
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── .gitignore
└── README.md
```## Installation & Setup
```shell
# enter your aws account on local
$ aws configure
AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY
Default region name [None]: ap-northeast-2
Default output format [None]: json
``````shell
# check aws account info
$ aws sts get-caller-identity
{
"UserId": "AIDXXXXXXXXXXXXXX",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/YourUserName"
}
``````shell
# move to /env/dev folder
cd env/dev
``````shell
# setting env variable to terraform.tfvars file
cat < terraform.tfvars
vpc_cidr_block = "172.21.0.0/16"
vpc_name = "search-vpc-dev"az_count = 2
environment = "dev"alb_listener_port = "80"
container_port = 3000# Private ECR Repository Image ARN
container_image = "6xxxxxxxxxxxxx.dkr.ecr.ap-northeast-2.amazonaws.com/nodejs"ecs_fargate_task_total_cpu = 2048
ecs_fargate_task_total_mem = 1024
ecs_task_desired_count = 1
domain = "search"
EOF
``````shell
# initialize terraform project
$ terraform init
``````shell
# validate terraform file
$ terraform validate
``````shell
# check terraform plan
$ terraform plan
``````shell
# apply & deploy terraform resource
$ terraform apply
``````shell
# destory all terraform resource
$ terraform destroy
```