Skip to content

Commit bfe25ea

Browse files
authored
BCDA-9727: Add Secondary Region KMS Key (#1292)
## 🎫 Ticket BCDA-9727 ## 🛠 Changes This change set updates the sops values files for all path-to-production environments to include both us-east-1 and us-west-2 homed KMS keys. This also simplifies the `10-config` terraform, introduces a mechanism for generating the distributed `sopsw` script via terraform input variable, introduces a root-level `.terraform-docs.yaml` configuration file for `terraform-docs`, and refreshes the included README. ## ℹ️ Context In the unlikely event of us-east-1 availability issues in SSM and/or KMS, we need to be able to use KMS keys homes in the BCP/GDR us-west-2 environment. This requires re-encryption of all encrypted values. Re-encryption was accommodated by decrypting previous sopsw values files via `sopsw -d` and re-encrypting with `sops -e` alongside appropriate `.sops.yaml` that encoded the comma-delimited kms keys in the following format: ``` creation_rules: - kms: arn:aws:kms:us-east-1:${aws_account_id}:alias/bcda-${env},arn:aws:kms:us-west-2:${aws_account_id}:alias/bcda-${env} unencrypted_regex: /nonsensitive/ mac_only_encrypted: true stores: yaml: indent: 2 ``` ## 🧪 Validation `tofu` invocations and the following `sopsw` commands continue to function under `10-config` with authenticated shells: ```sh bin/sopsw -d values/dev.sopsw.yaml bin/sopsw -d values/test.sopsw.yaml bin/sopsw -d values/sandbox.sopsw.yaml bin/sopsw -d values/prod.sopsw.yaml ```
1 parent 7444e04 commit bfe25ea

File tree

8 files changed

+811
-671
lines changed

8 files changed

+811
-671
lines changed

.terraform-docs.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
formatter: markdown table
2+
sections:
3+
show:
4+
- providers
5+
- requirements
6+
- inputs
7+
- resources
8+
- outputs
9+
- data-sources
10+
- modules
11+
12+
# this `content` string is implemented as a golang template https://pkg.go.dev/text/template
13+
# updates here correspond to `{{ .Content }}` in `output.template` setting below
14+
content: |-
15+
{{ $warning := `<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
16+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
17+
Manually updating sections between TF_DOCS tags may be overwritten.
18+
See https://terraform-docs.io/user-guide/configuration/ for more information.
19+
-->`}}
20+
21+
{{- $warning }}
22+
{{ .Providers }}
23+
24+
{{ $warning }}
25+
{{ .Requirements }}
26+
27+
{{ $warning }}
28+
{{ .Inputs }}
29+
30+
{{ $warning }}
31+
{{ .Modules }}
32+
33+
{{ $warning }}
34+
{{ .Resources }}
35+
36+
{{ $warning }}
37+
{{ .Outputs }}
38+
39+
output:
40+
file: README.md
41+
mode: inject
42+
template: |-
43+
<!-- BEGIN_TF_DOCS -->
44+
{{ .Content }}
45+
<!-- END_TF_DOCS -->
46+
47+
sort:
48+
enabled: true
49+
by: required
50+
51+
settings:
52+
indent: 2
53+
default: true
54+
required: true
55+
type: true

ops/services/10-config/README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ First, initialize and apply the configuration with the `sopsw` script targeted.
1313
cd ops/services/10-config
1414
export TF_VAR_env=dev
1515
tofu init
16-
tofu apply -target module.sops.local_file.sopsw
16+
tofu apply -target 'module.sops.local_file.sopsw[0]' -var=create_local_sops_wrapper=true
1717
```
1818

1919
### Editing Encrypted Configuration
@@ -63,3 +63,67 @@ Configuration files follow this pattern:
6363

6464
### External Tools
6565
- **tofu** - For deploying configuration to AWS Parameter Store (`brew install opentofu`)
66+
67+
<!-- BEGIN_TF_DOCS -->
68+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
69+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
70+
Manually updating sections between TF_DOCS tags may be overwritten.
71+
See https://terraform-docs.io/user-guide/configuration/ for more information.
72+
-->
73+
## Providers
74+
75+
No providers.
76+
77+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
78+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
79+
Manually updating sections between TF_DOCS tags may be overwritten.
80+
See https://terraform-docs.io/user-guide/configuration/ for more information.
81+
-->
82+
## Requirements
83+
84+
No requirements.
85+
86+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
87+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
88+
Manually updating sections between TF_DOCS tags may be overwritten.
89+
See https://terraform-docs.io/user-guide/configuration/ for more information.
90+
-->
91+
## Inputs
92+
93+
| Name | Description | Type | Default | Required |
94+
|------|-------------|------|---------|:--------:|
95+
| <a name="input_env"></a> [env](#input\_env) | The application environment (dev, test, sandbox, prod) | `string` | n/a | yes |
96+
| <a name="input_create_local_sops_wrapper"></a> [create\_local\_sops\_wrapper](#input\_create\_local\_sops\_wrapper) | When `true`, creates sops wrapper file at `bin/sopsw`. | `bool` | `false` | no |
97+
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `"us-east-1"` | no |
98+
| <a name="input_secondary_region"></a> [secondary\_region](#input\_secondary\_region) | n/a | `string` | `"us-west-2"` | no |
99+
100+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
101+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
102+
Manually updating sections between TF_DOCS tags may be overwritten.
103+
See https://terraform-docs.io/user-guide/configuration/ for more information.
104+
-->
105+
## Modules
106+
107+
| Name | Source | Version |
108+
|------|--------|---------|
109+
| <a name="module_platform"></a> [platform](#module\_platform) | github.com/CMSgov/cdap//terraform/modules/platform | ff2ef539fb06f2c98f0e3ce0c8f922bdacb96d66 |
110+
| <a name="module_sops"></a> [sops](#module\_sops) | github.com/CMSgov/cdap//terraform/modules/sops | 8874310 |
111+
112+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
113+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
114+
Manually updating sections between TF_DOCS tags may be overwritten.
115+
See https://terraform-docs.io/user-guide/configuration/ for more information.
116+
-->
117+
## Resources
118+
119+
No resources.
120+
121+
<!--WARNING: GENERATED CONTENT with terraform-docs, e.g.
122+
'terraform-docs --config "$(git rev-parse --show-toplevel)/.terraform-docs.yml" .'
123+
Manually updating sections between TF_DOCS tags may be overwritten.
124+
See https://terraform-docs.io/user-guide/configuration/ for more information.
125+
-->
126+
## Outputs
127+
128+
No outputs.
129+
<!-- END_TF_DOCS -->

ops/services/10-config/main.tf

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
2-
default_tags = module.platform.default_tags
3-
service = "config"
2+
service = "config"
43
}
54

65
module "platform" {
@@ -14,11 +13,8 @@ module "platform" {
1413
}
1514

1615
module "sops" {
17-
source = "github.com/CMSgov/cdap//terraform/modules/sops?ref=ff2ef539fb06f2c98f0e3ce0c8f922bdacb96d66"
16+
source = "github.com/CMSgov/cdap//terraform/modules/sops?ref=8874310"
1817

19-
platform = module.platform
20-
}
21-
22-
output "edit" {
23-
value = module.sops.sopsw
18+
platform = module.platform
19+
create_local_sops_wrapper = var.create_local_sops_wrapper
2420
}

0 commit comments

Comments
 (0)