Provide a basic infraestructure for multiple stages (staging and prod) for the weather django app(https://github.com/rlopez0689/weather_project). Having a remote state on s3, a lock on dynamo db and a module source from a github repo.
- S3 Bucket with versioning enabled for managing the terraform state
- DynamoDB for locking the state
- For each env:
- A VPC
- 4 subnets, 2 private(for rds) and 2 public(for ec2)
- One Postgres RDS with subnet group
- Elasticcache with memcached
- One webserver cluster with autoscaling group for ec2 and route3 entry for personal domain
https://github.com/rodrigolopez0689/TerraformModules
This two environment variables are needed:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
There is a makefile for spinning the whole infraestructure Just fill the variables in the file
- S3_DIR
- DYNAMO_LOCK_DB
- DB_PASSWORD
- ZONE_ID
- DOMAIN_NAME
- WEATHER_API
And then you can run the makefile:
make webcluster
Or you can do it manually with the next steps:
cd global/s3
terraform init
terraform apply -var 'buket_name=YOURBUCKETNAME'
cd global/dynamo
terraform init
terraform apply -var 'dynamo_table_name=YOURDYNAMONAME'
cd stage/network
terraform init -backend-config="bucket=YOURBUCKETNAME" -backend-config="dynamodb_table=YOURDYNAMONAME"
terraform apply
cd stage/data-stores/mysql
terraform init -backend-config="bucket=YOUREBUCKETNAME" -backend-config="dynamodb_table=YOURDYNAMONAME"
terraform apply -auto-approve -var 'db_password=PASSWORDDB' -var 'bucket_name=YOURBUCKETNAME'
cd stage/services/webserver-cluster
terraform init -backend-config="bucket=YOURBUCKETNAME" -backend-config="dynamodb_table=YOURDYNAMONAME"
terraform apply -auto-approve -var 'bucket_name=YOURBUCKETNAME' -var 'zone_id=YOURZONEID -var 'domain_name=YOURDOMAINNAME'