Skip to content

Commit

Permalink
Plumb thru deletion_protection for Cloud Run services. (#559)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Moore <[email protected]>
  • Loading branch information
mattmoor authored Sep 18, 2024
1 parent cbe0ed8 commit 652a950
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/regional-go-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_containers"></a> [containers](#input\_containers) | The containers to run in the service. Each container will be run in each region. | <pre>map(object({<br> source = object({<br> base_image = optional(string, "cgr.dev/chainguard/static:latest-glibc")<br> working_dir = string<br> importpath = string<br> env = optional(list(string), [])<br> })<br> args = optional(list(string), [])<br> ports = optional(list(object({<br> name = optional(string, "http1")<br> container_port = number<br> })), [])<br> resources = optional(<br> object(<br> {<br> limits = optional(object(<br> {<br> cpu = string<br> memory = string<br> }<br> ), null)<br> cpu_idle = optional(bool, true)<br> startup_cpu_boost = optional(bool, true)<br> }<br> ),<br> {<br> cpu_idle = true<br> }<br> )<br> env = optional(list(object({<br> name = string<br> value = optional(string)<br> value_source = optional(object({<br> secret_key_ref = object({<br> secret = string<br> version = string<br> })<br> }), null)<br> })), [])<br> regional-env = optional(list(object({<br> name = string<br> value = map(string)<br> })), [])<br> volume_mounts = optional(list(object({<br> name = string<br> mount_path = string<br> })), [])<br> }))</pre> | n/a | yes |
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | Whether to enable delete protection for the service. | `bool` | `true` | no |
| <a name="input_egress"></a> [egress](#input\_egress) | Which type of egress traffic to send through the VPC.<br><br>- ALL\_TRAFFIC sends all traffic through regional VPC network<br>- PRIVATE\_RANGES\_ONLY sends only traffic to private IP addresses through regional VPC network | `string` | `"ALL_TRAFFIC"` | no |
| <a name="input_enable_profiler"></a> [enable\_profiler](#input\_enable\_profiler) | Enable cloud profiler. | `bool` | `false` | no |
| <a name="input_execution_environment"></a> [execution\_environment](#input\_execution\_environment) | The execution environment for the service | `string` | `"EXECUTION_ENVIRONMENT_GEN1"` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/regional-go-service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module "this" {
ingress = var.ingress
egress = var.egress

deletion_protection = var.deletion_protection

service_account = var.service_account
containers = {
for name, container in var.containers : name => {
Expand Down
6 changes: 6 additions & 0 deletions modules/regional-go-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "service_account" {
description = "The service account as which to run the service."
}

variable "deletion_protection" {
type = bool
description = "Whether to enable delete protection for the service."
default = true
}

variable "containers" {
description = "The containers to run in the service. Each container will be run in each region."
type = map(object({
Expand Down
1 change: 1 addition & 0 deletions modules/regional-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_containers"></a> [containers](#input\_containers) | The containers to run in the service. Each container will be run in each region. | <pre>map(object({<br> image = string<br> args = optional(list(string), [])<br> ports = optional(list(object({<br> name = optional(string, "http1")<br> container_port = number<br> })), [])<br> resources = optional(<br> object(<br> {<br> limits = optional(object(<br> {<br> cpu = string<br> memory = string<br> }<br> ), null)<br> cpu_idle = optional(bool, true)<br> startup_cpu_boost = optional(bool, true)<br> }<br> ),<br> {<br> cpu_idle = true<br> }<br> )<br> env = optional(list(object({<br> name = string<br> value = optional(string)<br> value_source = optional(object({<br> secret_key_ref = object({<br> secret = string<br> version = string<br> })<br> }), null)<br> })), [])<br> regional-env = optional(list(object({<br> name = string<br> value = map(string)<br> })), [])<br> volume_mounts = optional(list(object({<br> name = string<br> mount_path = string<br> })), [])<br> }))</pre> | n/a | yes |
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | Whether to enable delete protection for the service. | `bool` | `true` | no |
| <a name="input_egress"></a> [egress](#input\_egress) | Which type of egress traffic to send through the VPC.<br><br>- ALL\_TRAFFIC sends all traffic through regional VPC network<br>- PRIVATE\_RANGES\_ONLY sends only traffic to private IP addresses through regional VPC network | `string` | `"ALL_TRAFFIC"` | no |
| <a name="input_enable_profiler"></a> [enable\_profiler](#input\_enable\_profiler) | Enable cloud profiler. | `bool` | `false` | no |
| <a name="input_execution_environment"></a> [execution\_environment](#input\_execution\_environment) | The execution environment for the service | `string` | `"EXECUTION_ENVIRONMENT_GEN1"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/regional-service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ resource "google_cloud_run_v2_service" "this" {

launch_stage = "BETA" // Needed for vpc_access below

deletion_protection = var.deletion_protection

template {
scaling {
Expand Down
6 changes: 6 additions & 0 deletions modules/regional-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "service_account" {
description = "The service account as which to run the service."
}

variable "deletion_protection" {
type = bool
description = "Whether to enable delete protection for the service."
default = true
}

variable "containers" {
description = "The containers to run in the service. Each container will be run in each region."
type = map(object({
Expand Down

0 comments on commit 652a950

Please sign in to comment.