Skip to content

Commit

Permalink
Allow mounting secrets to prober server (#365)
Browse files Browse the repository at this point in the history
Signed-off-by: Nghia Tran <tcnghia@gmail.com>
  • Loading branch information
tcnghia committed May 23, 2024
1 parent 6089f7d commit 564b5e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/prober/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ No requirements.
| <a name="input_period"></a> [period](#input\_period) | The period for the prober in seconds. | `string` | `"300s"` | no |
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The project that will host the prober. | `string` | n/a | yes |
| <a name="input_regions"></a> [regions](#input\_regions) | A map from region names to a network and subnetwork. A prober service will be created in each region. | <pre>map(object({<br> network = string<br> subnet = string<br> }))</pre> | n/a | yes |
| <a name="input_secret_env"></a> [secret\_env](#input\_secret\_env) | A map of secrets to mount as environment variables from Google Secrets Manager (e.g. secret\_key=secret\_name) | `map` | `{}` | no |
| <a name="input_service_account"></a> [service\_account](#input\_service\_account) | The email address of the service account to run the service as. | `string` | n/a | yes |
| <a name="input_slo_notification_channels"></a> [slo\_notification\_channels](#input\_slo\_notification\_channels) | A list of notification channels to send alerts to. | `list(string)` | `[]` | no |
| <a name="input_slo_policy_link"></a> [slo\_policy\_link](#input\_slo\_policy\_link) | An optional link to the SLO policy to include in the alert documentation. | `string` | `""` | no |
Expand Down
22 changes: 17 additions & 5 deletions modules/prober/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,23 @@ module "this" {
}
ports = [{ container_port = 8080 }]
env = concat([{
// This is a shared secret with the uptime check, which must be
// passed in an Authorization header for the probe to do work.
name = "AUTHORIZATION"
value = random_password.secret.result
}], [for k, v in var.env : { name = k, value = v }])
// This is a shared secret with the uptime check, which must be
// passed in an Authorization header for the probe to do work.
name = "AUTHORIZATION"
value = random_password.secret.result
}],
[for k, v in var.env : { name = k, value = v }],
[
for k, v in var.secret_env : {
name = k,
value_source = {
secret_key_ref = {
secret = v
version = "latest"
}
}
}
])
resources = {
limits = {
cpu = var.cpu
Expand Down
6 changes: 6 additions & 0 deletions modules/prober/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ variable "env" {
description = "A map of custom environment variables (e.g. key=value)"
}

variable "secret_env" {
default = {}
description = "A map of secrets to mount as environment variables from Google Secrets Manager (e.g. secret_key=secret_name)"
}

variable "timeout" {
type = string
default = "60s"
Expand Down Expand Up @@ -140,3 +145,4 @@ variable "enable_profiler" {
default = false
description = "Enable cloud profiler."
}

0 comments on commit 564b5e6

Please sign in to comment.