- Install Terraform
brew install terraform
-
Create AWS account Create account and create user
-
Create a S3 bucket
aws s3api create-bucket --bucket terraform-backend-store-<your_projectname> --region eu-central-1 --create-bucket-configuration LocationConstraint=eu-central-1
- Set credential for AWS user If you want to use existing user add aws access keys in ~/.aws/credentials and set the profile to use
export AWS_PROFILE=terraformuser
Information about use of named profiles is here
- AWS VPC
- Internet Gateway and Nat Gateway
- Subnets, RouteTables and routes
- ECS Cluster(Fargate)
- Secrets in secret manager
- Aurora Serverless databaase
- ALB TargetGroups
- ECS service which is spread accross multiple AZ with Autoscaling
- Security Groups
- Initialize the modules
cd dev
terraform init
- Create Secrets file
echo 'application-secrets = {
"VTT_DBUSER" = "postgres"
"VTT_DBPASSWORD" = "abcd123#$"
}
' > secrets.tfvars
- Plan resources
terraform plan -var-file="secrets.tfvars"
- Create resources
terraform apply -var-file="secrets.tfvars"
- VPC module is created from scratch to make it easier to go through the different components involved.
- ECS with Fargate is used instead of EKS to reduce complexity of managing and considering cost savings of not having to pay for cluster, since need to complex scaling or multi cloud requirements were not there ECS would be the simpler solution.
- ECS and ECS service module is created to have control over setup and be able to use it as a single module to make applying changes simple.
- RDS module from terraform registry is used to create highly available Aurora Serverless database.
- RDS on graviton used to reduce cost.
- Run on graviron2 for fargate
- CI pipeline