DEV Community

Cover image for Create an AWS ECS Cluster Using Terraform

Create an AWS ECS Cluster Using Terraform

Tacio Nery on April 09, 2021

Hey everyone, I'd like to share my experience with Terraform and AWS. In this post I'll describe the resources I used to build a infrastructure on ...
Collapse
 
fomm profile image
foMM

Thank you very much for this article. I got most things working except I am getting an error for the task to pull the ecr image. service call has been retried 3 time(s): RequestError: send request failed caused by: Post https://api.ecr.ap-southeast-2.amazonaws.com/: dial tcp 99.82.184.189:443: i/o timeout

Anyone got the same issue?

Collapse
 
felipeco14 profile image
Felipe Chaves de Oliveira

The problem is that your service/task is in a private subnet, and is not able to access the ECR registry, to solve this you need to create a NAT gateway to provide such access... stackoverflow.com/a/66802973

Collapse
 
vardyng profile image
Vardy • Edited

You must use us-east-1 to uplaod the image, while pulling image doesn't necessary in us-east-1

Collapse
 
petarmitrovic profile image
Petar

I found this article very helpful when setting up my ECS cluster.

A several improvements I'd like suggest:

  • use different roles for execution_role_arn and task_role_arn (in order to follow least permissions principle)
  • not store aws_access_key and aws_secret_key in .tfvars
Collapse
 
nmphuong200288 profile image
nmphuong200288

Hi brother.
data "template_file" "env_vars" {
template = file("env_vars.json")
i need the content of env_vars file. I don't know the content of that file also you can share me your github to minhphuong49th@gmail.com ? Thanks. I just start to learn terraform about three months

Collapse
 
softmarshmallow profile image
UZU, J

Github link is dead

Collapse
 
marcellodesales profile image
Marcello de Sales

Any idea on how to simplify your approach by creating the basics for aws.amazon.com/blogs/containers/au...?

Collapse
 
byronscottjones profile image
Byron Jones

The repo no longer exists.

Collapse
 
srak profile image
rak

Hi,
Any way to get the env_vars.json file?
Can't access the repository either is no longer avilable.

Cheers

Collapse
 
_farrukh_saeed profile image
Farrukh Saeed

Can someone tell me please, where is the best tutorial for learning Terraform.

Collapse
 
_farrukh_saeed profile image
Farrukh Saeed

Very nice article. Thanks for sharing.