@@ -8,46 +8,90 @@ An Ansible role for installing
8
8
9
9
## Pre-requisites (Ignore Until the COOL Migration) ##
10
10
11
- In order to execute the Molecule tests for this Ansible role in GitHub
12
- Actions, a build user must exist in AWS. The accompanying Terraform
13
- code will create the user with the appropriate name and
14
- permissions. This only needs to be run once per project, per AWS
15
- account. This user can also be used to run the Molecule tests on your
16
- local machine.
17
-
18
- Before the build user can be created, you will need a profile in your
19
- AWS credentials file that allows you to read and write your remote
20
- Terraform state. (You almost certainly do not want to use local
21
- Terraform state for this long-lived build user.) If the build user is
22
- to be created in the CISA COOL environment, for example, then you will
23
- need the ` cool-terraform-backend ` profile.
24
-
25
- The easiest way to set up the Terraform remote state profile is to
26
- make use of our
27
- [ ` aws-profile-sync ` ] ( https://github.com/cisagov/aws-profile-sync )
28
- utility. Follow the usage instructions in that repository before
29
- continuing with the next steps, and note that you will need to know
30
- where your team stores their remote profile data in order to use
11
+ In order to execute the Molecule tests for this Ansible role in GitHub Actions,
12
+ a test user must exist in AWS. The accompanying Terraform code will create the
13
+ user with the appropriate name and permissions. This only needs to be run once
14
+ per project, per AWS account. This user can also be used to run the Molecule
15
+ tests on your local machine.
16
+
17
+ Before the test user can be created, you will need a profile in your AWS
18
+ credentials file that allows you to read and write your remote Terraform state.
19
+ (You almost certainly do not want to use local Terraform state for this
20
+ long-lived test user.) If the test user is to be created in the CISA COOL
21
+ environment, for example, then you will need the ` cool-terraform-backend `
22
+ profile.
23
+
24
+ The easiest way to set up the Terraform remote state profile is to make use of
25
+ our [ ` aws-profile-sync ` ] ( https://github.com/cisagov/aws-profile-sync ) utility.
26
+ Follow the usage instructions in that repository before continuing with the next
27
+ steps, and note that you will need to know where your team stores their remote
28
+ profile data in order to use
31
29
[ ` aws-profile-sync ` ] ( https://github.com/cisagov/aws-profile-sync ) .
32
30
33
- To create the build user, follow these instructions:
31
+ ### Creating a test user ###
34
32
35
- ``` console
36
- cd terraform
37
- terraform init --upgrade=true
38
- terraform apply
39
- ```
33
+ You will need to create a test user for each environment that you use. The
34
+ following steps show how to create a test user for an environment named "dev".
35
+ You will need to repeat this process for any additional environments.
36
+
37
+ 1 . Change into the ` terraform ` directory:
38
+
39
+ ``` console
40
+ cd terraform
41
+ ```
42
+
43
+ 1 . Create a backend configuration file named ` dev.tfconfig ` containing the
44
+ name of the bucket where "dev" environment Terraform state is stored - this file
45
+ is required to initialize the Terraform backend in each environment:
46
+
47
+ ```hcl
48
+ bucket = "my-dev-terraform-state-bucket"
49
+ ```
50
+
51
+ 1 . Initialize the Terraform backend for the "dev" environment using your backend
52
+ configuration file:
53
+
54
+ ``` console
55
+ terraform init -backend-config=dev.tfconfig
56
+ ```
57
+
58
+ > [!NOTE]
59
+ > When performing this step for additional environments (i.e. not your first
60
+ > environment), use the `-reconfigure` flag:
61
+ >
62
+ > ```console
63
+ > terraform init -backend-config=other-env.tfconfig -reconfigure
64
+ > ```
65
+
66
+ 1. Create a Terraform variables file named `dev.tfvars` containing all
67
+ required variables (currently only `terraform_state_bucket`):
68
+
69
+ ```hcl
70
+ terraform_state_bucket = "my-dev-terraform-state-bucket"
71
+ ```
72
+
73
+ 1. Create a Terraform workspace for the "dev" environment:
74
+
75
+ ```console
76
+ terraform workspace new dev
77
+ ```
78
+
79
+ 1 . Initialize and upgrade the Terraform workspace, then apply the configuration
80
+ to create the test user in the "dev" environment:
81
+
82
+ ``` console
83
+ terraform init -upgrade=true
84
+ terraform apply -var-file=dev.tfvars
85
+ ```
40
86
41
- Once the user is created you will need to update the [ repository's
42
- secrets] ( https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets )
43
- with the new encrypted environment variables. This should be done
44
- using the
87
+ Once the test user is created you will need to update the
88
+ [repository's secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
89
+ with the new encrypted environment variables. This should be done using the
45
90
[`terraform-to-secrets`](https://github.com/cisagov/development-guide/tree/develop/project_setup#terraform-iam-credentials-to-github-secrets-)
46
- tool available in the [ development
47
- guide] ( https://github.com/cisagov/development-guide ) . Instructions for
48
- how to use this tool can be found in the [ "Terraform IAM Credentials
49
- to GitHub Secrets"
50
- section] ( https://github.com/cisagov/development-guide/tree/develop/project_setup#terraform-iam-credentials-to-github-secrets- ) .
91
+ tool available in the
92
+ [development guide](https://github.com/cisagov/development-guide). Instructions
93
+ for how to use this tool can be found in the
94
+ ["Terraform IAM Credentials to GitHub Secrets" section](https://github.com/cisagov/development-guide/tree/develop/project_setup#terraform-iam-credentials-to-github-secrets-).
51
95
of the Project Setup README.
52
96
53
97
If you have appropriate permissions for the repository you can view
0 commit comments