|
| 1 | +# `secret` |
| 2 | + |
| 3 | +This module encapsulates the creation of a Google Secret Manager secret to hold |
| 4 | +sensitive data in a manner that can be used as an environment variable or |
| 5 | +volume with Cloud Run. Unlike `configmap` this data is considered sensitive and |
| 6 | +so it is NOT loaded directly by this logic, but by an authorized party. Notably, |
| 7 | +the built-in alert policy WILL fire when the authorized party loads new values |
| 8 | +into the secret, this is by design. |
| 9 | + |
| 10 | +```hcl |
| 11 | +module "my-secret" { |
| 12 | + source = "chainguard-dev/common/infra//modules/secret" |
| 13 | +
|
| 14 | + project_id = var.project_id |
| 15 | + name = "my-secret" |
| 16 | +
|
| 17 | + # What the service accessing this configuration will run as. |
| 18 | + service-account = google_service_account.foo.email |
| 19 | +
|
| 20 | + # What group of identities are authorized to add new secret versions. |
| 21 | + authorized-adder = "group:[email protected]" |
| 22 | +
|
| 23 | + # Optionally: channels to notify if this secret is manipulated. |
| 24 | + notification-channels = [ ... ] |
| 25 | +} |
| 26 | +
|
| 27 | +module "foo-service" { |
| 28 | + source = "chainguard-dev/common/infra//modules/regional-go-service" |
| 29 | + project_id = var.project_id |
| 30 | + name = "foo" |
| 31 | + regions = module.networking.regional-networks |
| 32 | +
|
| 33 | + service_account = google_service_account.foo.email |
| 34 | + containers = { |
| 35 | + "foo" = { |
| 36 | + source = { |
| 37 | + working_dir = path.module |
| 38 | + importpath = "./cmd/foo" |
| 39 | + } |
| 40 | + ports = [{ container_port = 8080 }] |
| 41 | + volume_mounts = [{ |
| 42 | + name = "foo" |
| 43 | + mount_path = "/var/run/foo/" |
| 44 | + }] |
| 45 | + } |
| 46 | + } |
| 47 | + volumes = [{ |
| 48 | + name = "foo" |
| 49 | + secret = { |
| 50 | + secret = module.my-secret.secret_id |
| 51 | + items = [{ |
| 52 | + version = "latest" |
| 53 | + path = "my-filename" |
| 54 | + }] |
| 55 | + } |
| 56 | + }] |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +<!-- BEGIN_TF_DOCS --> |
| 61 | +## Requirements |
| 62 | + |
| 63 | +No requirements. |
| 64 | + |
| 65 | +## Providers |
| 66 | + |
| 67 | +| Name | Version | |
| 68 | +|------|---------| |
| 69 | +| <a name="provider_google"></a> [google](#provider\_google) | n/a | |
| 70 | + |
| 71 | +## Modules |
| 72 | + |
| 73 | +No modules. |
| 74 | + |
| 75 | +## Resources |
| 76 | + |
| 77 | +| Name | Type | |
| 78 | +|------|------| |
| 79 | +| [google_monitoring_alert_policy.anomalous-secret-access](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy) | resource | |
| 80 | +| [google_secret_manager_secret.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret) | resource | |
| 81 | +| [google_secret_manager_secret_iam_binding.authorize-service-access](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret_iam_binding) | resource | |
| 82 | +| [google_secret_manager_secret_iam_binding.authorize-version-adder](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/secret_manager_secret_iam_binding) | resource | |
| 83 | +| [google_client_openid_userinfo.me](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_openid_userinfo) | data source | |
| 84 | +| [google_project.project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source | |
| 85 | + |
| 86 | +## Inputs |
| 87 | + |
| 88 | +| Name | Description | Type | Default | Required | |
| 89 | +|------|-------------|------|---------|:--------:| |
| 90 | +| <a name="input_authorized-adder"></a> [authorized-adder](#input\_authorized-adder) | A member-style representation of the identity authorized to add new secret values (e.g. group:oncall@my-corp.dev). | `string` | n/a | yes | |
| 91 | +| <a name="input_name"></a> [name](#input\_name) | The name to give the secret. | `string` | n/a | yes | |
| 92 | +| <a name="input_notification-channels"></a> [notification-channels](#input\_notification-channels) | The channels to notify if the configuration data is improperly accessed. | `list(string)` | `[]` | no | |
| 93 | +| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | n/a | `string` | n/a | yes | |
| 94 | +| <a name="input_service-account"></a> [service-account](#input\_service-account) | The email of the service account that will access the secret. | `string` | n/a | yes | |
| 95 | + |
| 96 | +## Outputs |
| 97 | + |
| 98 | +| Name | Description | |
| 99 | +|------|-------------| |
| 100 | +| <a name="output_secret_id"></a> [secret\_id](#output\_secret\_id) | The ID of the secret. | |
| 101 | +<!-- END_TF_DOCS --> |
0 commit comments