AWS Three Tier Architecture Reference
This is an implementation of the classic three tier architecture for application hosting.
Three modules that constructs our architecture:
Setup:
- Install Terraform
- Setup your credentials via AWS Provider
- Run Three Tier Init with the corresponding env value to setup terraform backend with s3 bucket and dynamodb
- Clone this project
Run commands to deploy:
export env=dev (or prod)
terraform get -update=true
terraform init -backend-config=config/backend-${env}.conf -backend=true
terraform apply -var-file=config/${env}.tfvars -var password=<db password> -lock=true
Learn more about Terraform commands here
There are two example configuration files in the config/
folder. Each contains inputs for the main terraform module to run.
- dev: for development environment settings
- prod: for production like environment settings
Name | Description | Type | Default | Required |
---|---|---|---|---|
allocated_storage | The amount of allocated storage | string | - | yes |
db_subnet_b_cidr | The cidr range for db subnet b | string | - | yes |
db_subnet_c_cidr | The cidr range for db subnet c | string | - | yes |
instance_class | RDS instance class (e.g. db.t2.micro or db.m4.xlarge) | string | - | yes |
multi_az | Create a replica in different zone if set to true | string | - | yes |
password | RDS password | string | - | yes |
private_subnet_b_cidr | The cidr range for private subnet b | string | - | yes |
private_subnet_c_cidr | The cidr range for private subnet c | string | - | yes |
public_subnet_b_cidr | The cidr range for public subnet b | string | - | yes |
public_subnet_c_cidr | The cidr range for public subnet c | string | - | yes |
skip_final_snapshot | Creates a snapshot when db is deleted if set to true | string | - | yes |
username | RDS username | string | - | yes |
vpc_cidr | The cidr range for vpc | string | - | yes |
Name | Description |
---|---|
elb_dns | Elastic Load Balancer DNS |
rds_endpoint | RDS endpoint |
- https://github.com/BWITS/terraform-best-practices#run-terraform-from-docker-container
- https://github.com/terraform-community-modules
- https://opencredo.com/terraform-infrastructure-design-patterns/
- https://github.com/terraform-providers/terraform-provider-aws/tree/master/examples/rds
- https://github.com/gruntwork-io/terragrunt-infrastructure-modules-example