This is the terraform recipes we use to generate our production environment. This is in phase out mode and will be replaced by infra.
This repo is compatible with Terraform v0.11.14. To install this specific version use tfenv
brew install tfenv
tfenv install 0.11.14
Then follow these steps to init your environment
cp env.sample .env
and replace variables with valid AWS credentials with permissions we need to create all the infrastructuresource .env
make init
When you are making a change, follow this loop
make plan
to see your changes in memorymake apply
to apply changes
make apply
will also upload the terraform.tfvars
file (that is
ignored from the git repository since it has sensible data). When you
run make init
this file will be pulled from the remote.
If more than one person is modifying these files, you can make sure you
have the latest terraform.tfvars
file by running make tfvars-pull
.
This command will override your local terraform.tfvars
file, and since
is not commited to git, you will lose your changes (if any)
Each environment has its own folder under the environments
folder.
The easiest way to create a new environment is by copying an existing one
- Copy any environment you like to replicate to a new folder and cd there
- Delete ssh keys (
rm key_pair_*
) and create new ones (ssh-keygen -f key_pair_${env}
) - Change
Makefile
andmain.tf
environment variable to match the folder name - Run
make init
RDS databases are only reachable from an instance in the ec2_security_group. You can connect to the database using an SSH tunnel
ssh -N -L 9998:<rds_address>:5432 ubuntu@<instance-ip> -p 12345
Then connect to the database using the tunnel
psql -h localhost -p 9998 -d debtcollective_prod -U debtcollective < backup.sql