This repository is the near-simplest example of deploying an provisioning a web server on Amazon Web Services (AWS), using Terraform and Ansible. The Terraform part is based on their Basic Two-Tier AWS Architecture example.
This repository sets up:
- A VPC
- A subnet
- An internet gateway
- A security group
- An SSH key pair
- A publicly-accessible EC2 instance
- Within the instance:
- Python 2 (for Ansible)
- Nginx
- Install the following locally:
- Terraform
- Terraform Inventory
- Python 2
- pip
- Set up AWS credentials in
~/.aws/credentials
.- The easiest way to do so is by setting up the AWS CLI.
- Ensure you have an SSH public key at
~/.ssh/id_rsa.pub
.
./deploy.sh
If it is successful, you should see an address
printed out at the end. Visit this in your browser, and the page should say "Welcome to nginx!"
-
./deploy.sh
is idempotent. -
If you have multiple AWS accounts/profiles, run with
AWS_PROFILE=something ./deploy.sh
-
You can override any of the Terraform variables using a
terraform.tfvars
file under theterraform/
directory.