Skip to content

Commit 51186a2

Browse files
authored
Merge pull request #2 from masterpointio/fix/update_example
fix: update to a working example
2 parents 50fea73 + 9bc54ab commit 51186a2

File tree

6 files changed

+39
-8
lines changed

6 files changed

+39
-8
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ Copy `exports/secrets.sops.tf` to your project by running the following command:
1818
curl -sL https://raw.githubusercontent.com/masterpointio/terraform-secrets-helper/main/exports/exports/secrets.sops.tf -o exports/secrets.sops.tf
1919
```
2020

21-
The mixin incorporates the invocation of this module, so you simply need to configure the necessary variable and then reference it within your code.
21+
The mixin incorporates the invocation of this module, so you simply need to configure the required `secret_mapping` variable and then reference it within your code.
22+
23+
See the full example in [examples/complete](https://github.com/masterpointio/terraform-secrets-helper/tree/main/examples/complete)
2224

2325
```hcl
2426
secret_mapping = [{
2527
name = "db_password"
26-
file = "../../config/secrets/dev.yaml"
28+
file = "test.yaml"
2729
type = "sops"
2830
}]
2931
32+
3033
output "db_password" {
3134
value = jsonencode(local.secrets["db_password"])
3235
sensitive = true

examples/complete/key.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This is a key created by [age](https://github.com/getsops/sops#encrypting-using-age) for this example only.
2+
# Don't use it to encrypt real secrets.
3+
# public key: age16s8ufjce303p3z2vxvf066rm37ueh4jyrk6tneectcf4ndkkwffqw6xrwp
4+
AGE-SECRET-KEY-10LCLHZDG25ECPN4RHGKNCSN8K473Q6ZSCN440HAQKC3T0DKQY8MQYG7ERM

examples/complete/outputs.tf

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# In this example we assume that the mixin `../../exports/secrets.sops.tf` is placed next to `outputs.tf`,
2-
# `so local.secrets` is available.
1+
# In this example we assume that the mixin `../../exports/secrets.sops.tf` is placed next to `outputs.tf`, `so local.secrets` is available.
2+
# The secrets file `test.yaml` is encrypted by tool `age`, see more https://github.com/getsops/sops#encrypting-using-age.
3+
#
4+
# To decrypt and view the secrets file, run `SOPS_AGE_KEY_FILE=key.txt sops test.yaml`.
5+
# To run Terraform commands - pass the age key file as well, e.g.: `SOPS_AGE_KEY_FILE=key.txt terraform apply`.
36

47
output "db_password" {
58
value = jsonencode(local.secrets["db_password"])
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
secret_mapping = [{
22
name = "db_password"
3-
file = "../../config/secrets/dev.yaml"
3+
file = "test.yaml"
44
type = "sops"
55
}]

examples/complete/test.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
db_password: ENC[AES256_GCM,data:rten3dguCu7Sna/c6KrNehzF5obQaHfHPA3HKK+WfDtMMim53TI=,iv:gYp+m5ukEpdpaNG8oxWf+0z22qcqkepkbTkirwBGFSU=,tag:sEOOCfOIcRTjXgHyXXtcfg==,type:str]
2+
sops:
3+
kms: []
4+
gcp_kms: []
5+
azure_kv: []
6+
hc_vault: []
7+
age:
8+
- recipient: age16s8ufjce303p3z2vxvf066rm37ueh4jyrk6tneectcf4ndkkwffqw6xrwp
9+
enc: |
10+
-----BEGIN AGE ENCRYPTED FILE-----
11+
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBaVkhPdHlpL0FOU3hFVmg0
12+
UnNuV1YrRzRGRFZGMG1UQ0Vvc1RJSm55bTBNClVnZmpYVURsdnRHVWYxLytzdFdQ
13+
SDkwYXR4QXdTQUg2VURIaEE1Q0ovNlUKLS0tIGJ4QW02dm1zd1ZEVDk4ZDExbnVm
14+
bHc0S1liTmlCb3V6WEhaL3p1RjdXRXMKZtATzGojbybk5oZTVjaJej30Alt7K7bZ
15+
bJ+KeVop2hnYiXS8JkTJ5OO6eE/5pemihyfLdgi6dBpquNr9jE2Kug==
16+
-----END AGE ENCRYPTED FILE-----
17+
lastmodified: "2023-07-30T12:40:33Z"
18+
mac: ENC[AES256_GCM,data:wBznFHw0buGoEyr8v93SmnWsaf3NVKPzipa/1ckWtW1tgZDycqSY1PoxFH9gd9OEnKX8Iyz2EsFIG5WikDlkSFx0OEsx5RSDIB/exF+MQjIOmE+rNk7QuJl7v9c5Hel/XKtp9SNTvqewzRAXn1c8NxheenKi1o/13YA7JSMLjes=,iv:5mz5CJkD9ZDxolfCEDbwXntvauLy45RI8mzoVhSWT1E=,tag:V4i8mrS9Ddx7L9Fm7kr19Q==,type:str]
19+
pgp: []
20+
unencrypted_suffix: _unencrypted
21+
version: 3.7.3

exports/secrets.sops.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module "secrets" {
2-
# Will be updated once we release a version and publish to the registry
3-
# checkov:skip=CKV_TF_1:This module source will be updated soon, skipping this check.
4-
source = "git::https://github.com/masterpointio/terraform-secrets-helper.git?ref=tags/X.X.X"
2+
# checkov:skip=CKV_TF_1: For now we use Terraform registry source, not git. If switching to git, we should use a commit hash.
3+
source = "masterpointio/helper/secrets"
4+
version = "0.2.0"
55
secret_mapping = var.secret_mapping
66
}
77

0 commit comments

Comments
 (0)