Programmed by [email protected]
If you are developing applications for Cloud, you want to spend most of your time doing exactly that.
Manually setting up cloud infrastructure for your application, takes away precious time, that you could use to generate end user value. It is error prone, not repeatable and has key man dependency.
Terraform allows to deliver Infrastructure as Code.
- You can script your environment state.
- Replicate the infrastructure to another environment.
- Source control the script to see how infrastructure has evolved over time.
- Compare infrastructure state between different environment using terraform state files.
Use the script below to setup a modern cloud infrastructure for your web application.
Download the script from this repository, navigate to directory where the script resides and run it as below :
terraform apply
It will prompt you for some AWS credentials (secret key, access key, private key path etc).
It will generate :
- Virtual Private Cloud (VPC)
- Configurable number of Subnets in the VPC
- Create a template EC2 Instance with Nginx server, and other setup.
- Create a AMI with above template EC2 Instance.
- Amazon EC2 instances and Subnets are spread out over multiple availablility regions
- Set up Application Load Balancer
- Configure Nginx logs to go to S3 bucket
- Create Autoscaling configuration using above AMI.
- Navigate to the URL shown in script output, if all has gone well, you will see nginx webserver's default web page.
To clean up this environment :
terraform destroy
- Make sure you have a user with appropriate permissions
- Create access key for this user in AWS web console
- Download the key file.