Skip to content

Commit

Permalink
Fix ipv6 output in net-vpc module, add support for extra volumes in c…
Browse files Browse the repository at this point in the history
…loud run v2 module (#2638)

* fix #2637

* fix #2635
  • Loading branch information
ludoo authored Oct 24, 2024
1 parent 24d78de commit 601f137
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/cloud-run-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ module "cloud_run" {
| [service_account](variables.tf#L221) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L227) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [tag_bindings](variables.tf#L233) | Tag bindings for this service, in key => tag value id format. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [volumes](variables.tf#L240) | Named volumes in containers in name => attributes format. | <code title="map&#40;object&#40;&#123;&#10; secret &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; default_mode &#61; optional&#40;string&#41;&#10; path &#61; optional&#40;string&#41;&#10; version &#61; optional&#40;string&#41;&#10; mode &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; cloud_sql_instances &#61; optional&#40;list&#40;string&#41;&#41;&#10; empty_dir_size &#61; optional&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [volumes](variables.tf#L240) | Named volumes in containers in name => attributes format. | <code title="map&#40;object&#40;&#123;&#10; secret &#61; optional&#40;object&#40;&#123;&#10; name &#61; string&#10; default_mode &#61; optional&#40;string&#41;&#10; path &#61; optional&#40;string&#41;&#10; version &#61; optional&#40;string&#41;&#10; mode &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; cloud_sql_instances &#61; optional&#40;list&#40;string&#41;&#41;&#10; empty_dir_size &#61; optional&#40;string&#41;&#10; gcs &#61; optional&#40;object&#40;&#123;&#10; bucket &#61; string&#10; is_read_only &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10; nfs &#61; optional&#40;object&#40;&#123;&#10; server &#61; string&#10; path &#61; optional&#40;string&#41;&#10; is_read_only &#61; optional&#40;bool&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [vpc_connector_create](variables-vpcconnector.tf#L17) | Populate this to create a Serverless VPC Access connector. | <code title="object&#40;&#123;&#10; ip_cidr_range &#61; optional&#40;string&#41;&#10; machine_type &#61; optional&#40;string&#41;&#10; name &#61; optional&#40;string&#41;&#10; network &#61; optional&#40;string&#41;&#10; instances &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number&#41;&#10; min &#61; optional&#40;number&#41;&#10; &#125;&#41;, &#123;&#125;&#10; &#41;&#10; throughput &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number&#41;&#10; min &#61; optional&#40;number&#41;&#10; &#125;&#41;, &#123;&#125;&#10; &#41;&#10; subnet &#61; optional&#40;object&#40;&#123;&#10; name &#61; optional&#40;string&#41;&#10; project_id &#61; optional&#40;string&#41;&#10; &#125;&#41;, &#123;&#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs
Expand Down
15 changes: 15 additions & 0 deletions modules/cloud-run-v2/job.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ resource "google_cloud_run_v2_job" "job" {
size_limit = volumes.value.empty_dir_size
}
}
dynamic "gcs" {
for_each = volumes.value.gcs == null ? [] : [""]
content {
bucket = volumes.value.bucket
read_only = volumes.value.is_read_only
}
}
dynamic "nfs" {
for_each = volumes.value.nfs == null ? [] : [""]
content {
server = volumes.value.server
path = volumes.value.path
read_only = volumes.value.is_read_only
}
}
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions modules/cloud-run-v2/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ resource "google_cloud_run_v2_service" "service" {
size_limit = volumes.value.empty_dir_size
}
}
dynamic "gcs" {
for_each = volumes.value.gcs == null ? [] : [""]
content {
bucket = volumes.value.bucket
read_only = volumes.value.is_read_only
}
}
dynamic "nfs" {
for_each = volumes.value.nfs == null ? [] : [""]
content {
server = volumes.value.server
path = volumes.value.path
read_only = volumes.value.is_read_only
}
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions modules/cloud-run-v2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,24 @@ variable "volumes" {
}))
cloud_sql_instances = optional(list(string))
empty_dir_size = optional(string)
gcs = optional(object({
# needs revision.gen2_execution_environment
bucket = string
is_read_only = optional(bool)
}))
nfs = optional(object({
server = string
path = optional(string)
is_read_only = optional(bool)
}))
}))
default = {}
nullable = false
validation {
condition = alltrue([
for k, v in var.volumes :
sum([for kk, vv in v : vv == null ? 0 : 1]) == 1
])
error_message = "Only one type of volume can be defined at a time."
}
}
2 changes: 1 addition & 1 deletion modules/net-vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ output "id" {

output "internal_ipv6_range" {
description = "ULA range."
value = try(local.network.internal_ipv6_range, null)
value = try(google_compute_network.network[0].internal_ipv6_range, null)
}

output "name" {
Expand Down

0 comments on commit 601f137

Please sign in to comment.