The infrastructure is created in AWS.
To create it we use Terraform which allows us to automate resource creation by defining them programmatically.
For more information on how Terraform works visit the Getting Started guide and the documentation. For more specific information about how it interacts with AWS check out the AWS Provider Documentation.
- You need to have Terraform installed, check the downloads page
- You also need some AWS Credentials
We use various AWS services:
- Amazon S3 for asset storage
- Cloudfront as an asset cache to optimise asset distribution
- Route53 to manage our DNS and link the domain to our Cloudfront distribution
infrastructure/
├── resources/
│ ├── buckets.tf
│ ├── cloudfront.tf
│ ├── domain.tf
│ └── variables.tf
├── main.tf
├── outputs.tf
├── README.md
├── terraform.tfvars
└── variables.tf
-
variables.tf
: This file defines the variables required to create the infrastructure -
main.tf
: This is where everything starts, this file defines the minimum Terraform version, the providers and the modules we have -
terraform.tfvars
: The value for the variables defined above, DO NOT COMMIT THIS TO THE REPOSITORY -
outputs.tf
: After runningterraform apply
this will print the configured outputs to the console -
resources/
: This folder is a Terraform module, it holds all the resources needed for a static sitevariables.tf
: The variables required by the modulebuckets.tf
: Create the S3 buckets with the policies already configured.cloudfront.tf
: Creates the Cloudfront that uses the S3 as the sourcedomain.tf
: Creates the domain record in Route53 and point it to the Cloudfront
Rename the terraform.tfvars.example
file to be terraform.tfvars
:
mv terraform.tfvars.example terraform.tfvars
Modify the file to use your specific credentials:
aws_access_key = "your access key"
aws_secret_key = "your secret key"
Initialize terraform
terraform init
If everything is correct the following command should output an execution plan
terraform plan
If everything looks good to go you can apply the changes with
terraform apply