Terraform is an infrastructure as code (IaC) that can help you to manage your infrastructure with configuration files and cli
Terraform has many provider that can connect the terraform itself and the service such as AWS, Azure, GCP, k8s and many more.
It can manage your infrastructure such as
- Making new contiainers
- Adding policies to service
- Creating auto scaling
- And many more!
- Terraform
- Prefered provider (In this case AWS)
- Install terraform by following the guide in the requirements
- Clone the repository using
git clone https://github.com/IloveNooodles/Terraform-ECS-Nginx-Clusteror download the zip version - Generate
Access keyandSecret keyand if you don't understand what it is please refer to this document - Create
terraform.tvarsby copyingterraform.tfvars.example - Fill your prefered-region (default: us-east-1)
- Fill the
aws_access_key_idandaws_secret_access_keythat you got from the aws website - Run
terraform initto createterraform.lockfile - Run
terraform planto create the build plan - If you satisfied with the current plan you can run
terraform applyto create your configuration in your provider - If
applyis successful then console will output the url you can visit!
...SNIP...
Apply complete! Resources: 28 added, 0 changed, 0 destroyed.
Outputs:
alb_hostname = "nginx-load-balancer-559564577.us-east-1.elb.amazonaws.com"
- Run
terraform destroyto destory all the instance.
Note: all variables defined in the variables.tf and it can be changed or provide it with the same name in .tfvars if you're not satisfied with the configuration