|
| 1 | +# NRLF Backup Infrastructure |
| 2 | + |
| 3 | +This directory contains AWS backup terraform resources which are global to a given account. |
| 4 | + |
| 5 | +Each subdirectory corresponds to each AWS account (`prod` and `test`). |
| 6 | + |
| 7 | +**Backup infrastructure should be deployed manually and not be run as part of CI.** |
| 8 | + |
| 9 | +## Table of Contents |
| 10 | + |
| 11 | +1. [Prerequisites](#prerequisites) |
| 12 | +2. [Initialise shell environment](#initialise-shell-environment) |
| 13 | +3. [Deploy backup resources](#deploy-backup-resources) |
| 14 | +4. [Tear down backup resources](#tear-down-backup-resources) |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +Before deploying the NRLF backup infrastructure, you will need: |
| 19 | + |
| 20 | +- An AWS backup account that have already been bootstrapped, as described in [bootstrap/README.md](../bootstrap/README.md). This is a one-time account setup step. |
| 21 | + |
| 22 | +## Deploy backup resources |
| 23 | + |
| 24 | +To deploy the backup resources, first login to the AWS mgmt account on the CLI. |
| 25 | + |
| 26 | +Then, initialise the terraform backup workspace. For the test account: |
| 27 | + |
| 28 | +```shell |
| 29 | +$ cd test |
| 30 | +$ terraform init && ( \ |
| 31 | + terraform workspace new backup-infra-test || \ |
| 32 | + terraform workspace select backup-infra-test ) |
| 33 | +``` |
| 34 | +
|
| 35 | +If you want to apply changes to prod, use the `prod` directory and the `backup-infra-prod` terraform workspace. |
| 36 | +
|
| 37 | +Once you have your workspace set, you can plan your changes with: |
| 38 | +
|
| 39 | +```shell |
| 40 | +$ terraform plan \ |
| 41 | + -var 'source_account_id=SOURCE_ACCOUNT_ID" \ |
| 42 | + -var 'assume_account=AWS_ACCOUNT_ID' \ |
| 43 | + -var 'assume_role=terraform' |
| 44 | +``` |
| 45 | +
|
| 46 | +Replacing SOURCE_ACCOUNT with the account id that will be sending backups to the backup account and AWS_ACCOUNT_ID with the AWS account id of your backup account. |
| 47 | +
|
| 48 | +Once you're happy with your planned changes, you can apply them with: |
| 49 | + |
| 50 | +```shell |
| 51 | +$ terraform apply \ |
| 52 | + -var 'source_account_id=SOURCE_ACCOUNT_ID" \ |
| 53 | + -var 'assume_account=AWS_ACCOUNT_ID' \ |
| 54 | + -var 'assume_role=terraform' |
| 55 | +``` |
| 56 | +
|
| 57 | +Replacing SOURCE_ACCOUNT with the account id that will be sending backups to the backup account and AWS_ACCOUNT_ID with the AWS account id of your backup account. |
| 58 | +
|
| 59 | +## Tear down backup resources |
| 60 | +
|
| 61 | +WARNING - This action will destroy all backup resources from the AWS account. This should |
| 62 | +only be done if you are sure that this is safe and are sure that you are signed into the correct |
| 63 | +AWS account. |
| 64 | +
|
| 65 | +To tear down backup resources, first login to the AWS mgmt account on the CLI. |
| 66 | +
|
| 67 | +Then, initialise your terraform workspace. For the test account: |
| 68 | +
|
| 69 | +```shell |
| 70 | +$ cd test |
| 71 | +$ terraform init && ( \ |
| 72 | + terraform workspace new backup-infra-test || \ |
| 73 | + terraform workspace select backup-infra-test ) |
| 74 | +``` |
| 75 | +
|
| 76 | +If you want to destroy resources in prod, use the `prod` directory and the `backup-infra-prod` terraform workspace. |
| 77 | +
|
| 78 | +And then, to tear down: |
| 79 | +
|
| 80 | +```shell |
| 81 | +$ terraform destroy \ |
| 82 | + -var 'source_account_id=SOURCE_ACCOUNT_ID" \ |
| 83 | + -var 'assume_account=AWS_ACCOUNT_ID' \ |
| 84 | + -var 'assume_role=terraform' |
| 85 | +``` |
| 86 | +
|
| 87 | +Replacing SOURCE_ACCOUNT with the account id that will be sending backups to the backup account and AWS_ACCOUNT_ID with the AWS account id of your backup account. |
0 commit comments