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-Cluster
or download the zip version - Generate
Access key
andSecret key
and if you don't understand what it is please refer to this document - Create
terraform.tvars
by copyingterraform.tfvars.example
- Fill your prefered-region (default: us-east-1)
- Fill the
aws_access_key_id
andaws_secret_access_key
that you got from the aws website - Run
terraform init
to createterraform.lock
file - Run
terraform plan
to create the build plan - If you satisfied with the current plan you can run
terraform apply
to create your configuration in your provider - If
apply
is 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 destroy
to 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