There are many issues involved when creating new project infrastructures.
Here's why:
- It's difficult to handle projects maintenance when there's no codified infrastructure, you don't know what and how much resources are being used.
- Cross development gets harder since there's no idea about how the application infrastructure work.
- The process of manually creating your infrastructure takes so much time.
- It's difficult to create an infrastructure cost prediction.
Due to these issues, Terraform is an IaC (Infrastructure as Code) tool to automate your setup.
To get your infrastructure up and running follow the steps:
aws configure
-
Create an AWS Secrets Manager secret to store your AWS secret access key, and grab its ARN.
-
Check the
fixtures.staging.us-west-2.tfvars
file variables, and set them according to your environment. Or create one file for another environment :).
- Go to the
remote-state
folder and initialize your remote state using AWS S3 and DynamoDB. (Optional, but recommended).
terraform init
terraform apply -var-file=../fixtures.staging.us-west-2.tfvars
- Install all modules required by this configuration.
cd ../
terraform init
- Apply your infrastructure based on environment variables. (Check
variables.tf
and create a terraform tfstate file if necessary)
terraform apply -var-file=fixtures.staging.us-west-2.tfvars
- (Optional) - If you want to estimate your infrastructure costs, so you may generate a terraform plan and analyze it with terraform cost estimation
terraform plan -var-file=fixtures.staging.us-west-2.tfvars -out=plan.tfplan && terraform show -json plan.tfplan > plan.json