This directory contains files needed for initial setup for brand new AWS accounts. Directory is split in to two sub directories. mgmt directory contains files required for initial bootstrap of the mgmt account. non-mgmt directory contains files required for initial bootstrap of prod, test and dev accounts.
The setup creates AWS resources to enable terraform deployments to AWS accounts. This should only be required to be performed once.
Before you begin deploying NRLF bootstrap components, you will need:
- Four AWS accounts created. These will be assigned as: mgmt, prod, test and dev
- The required packages to build NRLF, see the Setup section in README.md.
To bootstrap the environments, you need to follow these steps.
These steps should only need to be run once when starting the project
This will set up your terraform state buckets and import them into your project. It will create resources on mgmt account required for terraform to work. This includes:
- terraform state bucket
- terraform state lock table
- secret managers to hold account ids for the non-mgmt accounts
To create these resource, first login to the AWS mgmt account on your CLI and then run:
./scripts/bootstrap.sh create-mgmtNow log on to AWS web console and manually add the aws account ids to each respective secrets:
nhsd-nrlf--mgmt--mgmt-account-idnhsd-nrlf--mgmt--prod-account-idnhsd-nrlf--mgmt--test-account-idnhsd-nrlf--mgmt--test-backup-account-idnhsd-nrlf--mgmt--dev-account-id
Generate a Github PAT for the NRLF source repo and add it to the nhsd-nrlf--codebuild-github-pat secret following the documentation on AWS Codebuild Access Tokens for Github. This is required for codebuild to be used for Github Self-Hosted Runners.
In order to allow mgmt to create resources in prod, test and dev accounts you
need to create a trust role in each of these accounts.
To create this role, first login to your non-mgmt account on your CLI and then run:
./scripts/bootstrap.sh create-non-mgmtWhen closing AWS accounts, resources created by this setup will need to be torn down.
This will tear down resources created in this step
To tear down the non-mgmt account, first login to that non-mgmt AWS account on your CLI and then run:
./scripts/bootstrap.sh delete-non-mgmtThis will tear down resources created in this step.
To tear down management resource, first login to the AWS mgmt account on your CLI and then run:
./scripts/bootstrap.sh delete-mgmt