This is based off of code by Andrei Maksimov / Hands-On.Cloud
The original project code is on his github
The intention of this repo is to mock out a base configuration for an auto-scaling, load-balanced set of web servers with automatic SSL termination.
This is configured with the assumption that you have a Hosted Domain in AWS and that said domain has a Hosted Zone with the same name as is defined by the domain variable. It will NOT create or modify existing Hosted Zones.
-
Install terraform
-
Install aws cli
-
Generate an IAM access key for the user account you'll be using
terraformwith -
Create an aws cli Named Profile. This will be referred to in the
terraformvariables filevalues.tfvars
-
Copy example variables:
cp "values.tfvars.example" "values.tfvars" -
Modify
values.tfvarsfile with your desired variables and save -
Execute the following commands:
terraform init
terraform plan -out "my-plan.plan" -var-file="values.tfvars"
-
Carefully review your plan for accuracy!
-
Once satisfied, execute:
terraform apply my-plan.plan
- Wait a few minutes for your infrastructure to come online
This will spit out an AWS Key Pair associated with the instances spun up by Terraform. You will need to set the correct permissions in order to use it:
chmod 400 <my-keyfile.pem>
The default username for the AMI is ec2-user, so the correct SSH command would be:
ssh -i "/path/to/<my-keyfile.pem>" ec2-user@<your-instance-public-ip>