A simple IaaS deployment use-case using Terraform.
- An EC2 instance
- An EC2 Security Group
-
Create an AWS AMI User
-
Create an AWS EC2 Key Pair
-
Install
make
andtee
-
Install
bundle
(see Install Bundler) -
Install
pre-commit
(see Install pre-commit) -
Install
terraform
(see Install Terraform)
- Add the AWS credentials for your default and testing environments in
~/.aws/credentials
:
[default]
aws_access_key_id={YOUR_ACCESS_KEY_ID}
aws_secret_access_key={YOUR_SECRET_ACCESS_KEY}
[testing]
aws_access_key_id={YOUR_TESTING_ACCESS_KEY_ID}
aws_secret_access_key={YOUR_TESTING_SECRET_ACCESS_KEY}
Assuming you don't alter the settings in the next step, the credentials under testing will be used when testing deployments. Those under default will be used in all non-testing scenarios.
- Review the settings in
terraform-testing.tfvars.json
. These will apply only in testing:
{
"aws_profile": "testing",
"aws_region": "eu-west-1",
...
- Review the settings in
terraform.tfvars
(seevariables.tf
for supported settings and defaults):
{
"aws_profile": "default",
"aws_region": "eu-west-1",
...
The settings in terraform.tfvars
declare user-provided settings and would typically be created on-the-fly.
- Initialize the repository:
make init
- Test and deploy the infrastructure:
make all
- Destroy the infrastructure:
make destroy