This repository contains the Terraform configuration for the infrastructure of the Private Rented Sector Database (PRSDB) service. The main respository for the service, which includes Architecture Decision Records for this infrastructure can be found at https://github.com/communitiesuk/prsdb-webapp
TODO
- Create the new folder
terraform/<environment name>
and copy the contents ofterraform/environment_template
into it - In
terraform/<environment name>/backend
remove the.template
from the end of the file name and replace all instances of the string<environment name>
with your actual environment name. - Leave the block that starts with
backend "s3"
near the top of the file commented out cd
intoterraform/<environment name>/backend
and runterraform init
followed byterraform plan
. Among other things the plan should show the creation of an s3 bucket calledprsdb-tfstate-<environment name>
and a dynamoDB table namedtfstate-lock-<environment name>
. If everything looks correct with the plan output, runterraform apply
.- After the
apply
step completes successfully and you can see the s3 bucket and dynamoDB table in the aws console, uncomment thebackend "s3"
block and runterraform init
- You should be prompted to move the terraform state to the remote backend. Once this is done the terraform state is successfully bootstrapped for the new environment
- In your new
terraform/<environment name>
folder, you can now also remove the.template
from the end of all of the filenames, replace all instances of the string<environment name>
with your actual environment name, and more generally look throughmain.tf
for any sets of<>
that require environment-specific input, e.g. the domains of any 3rd party integrations.
- Before we can create the environment as a whole, we must first create the initial networking infrastructure, and then request the DNS names and certificates from MHCLG.
- One of the files in your new
terraform/<environment name>
folder will beterraform.tfvars
. Check that this contains the linessl_certs_created = false
- Once this is done,
cd
intoterraform/<environment name>
and runterraform init
followed byterraform plan -target module.networking -target module.frontdoor
. If the output of the plan looks correct, runterraform apply -target module.networking -target module.frontdoor
to bring up the networking for new environment. - In the terraform output you should see outputs for
cloudfront_dns_name
andload_balancer_dns_name
. Include these in the request to MHCLG For the domain names and certificates.
TODO: Document the request process for the domain names and certificates
- In
terraform.tfvars
setssl_certs_created
totrue
. - Then run
terraform plan
. If the output looks correct, runterraform apply
to bring up the environment.
This repository uses tfsec to scan the Terraform code for potential security issues. It can be run using Docker
docker run --pull=always --rm -it -v "$(pwd):/src" aquasec/tfsec /src
Individual rules can be ignored with a comment on the line above with the form tfsec:ignore:<rule-name>
e.g. tfsec:ignore:aws-dynamodb-enable-at-rest-encryption
.