Skip to content

Commit

Permalink
Add gcs mount_options, move direct vpc out of BETA
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorn committed Nov 16, 2024
1 parent 020aa8c commit 1cbbe62
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
25 changes: 12 additions & 13 deletions modules/cloud-run-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Cloud Run Services and Jobs, with support for IAM roles and Eventarc trigger cre
- [Mounting secrets as volumes](#mounting-secrets-as-volumes)
- [Mounting GCS buckets](#mounting-gcs-buckets)
- [Connecting to Cloud SQL database](#connecting-to-cloud-sql-database)
- [Beta features](#beta-features)
- [Direct VPC Egress](#direct-vpc-egress)
- [VPC Access Connector](#vpc-access-connector)
- [Using Customer-Managed Encryption Key](#using-customer-managed-encryption-key)
- [Eventarc triggers](#eventarc-triggers)
Expand Down Expand Up @@ -109,6 +109,10 @@ module "cloud_run" {
gcs = {
bucket = var.bucket
is_read_only = false
mount_options = [ # Beta feature
"metadata-cache-ttl-secs=120s",
"type-cache-max-size-mb=4",
]
}
}
}
Expand Down Expand Up @@ -143,18 +147,13 @@ module "cloud_run" {
# tftest fixtures=fixtures/cloudsql-instance.tf inventory=cloudsql.yaml e2e
```


## Beta features

To use beta features like Direct VPC Egress, set the launch stage to a preview stage.

## Direct VPC Egress
```hcl
module "cloud_run" {
source = "./fabric/modules/cloud-run-v2"
project_id = var.project_id
name = "hello"
region = var.region
launch_stage = "BETA"
source = "./fabric/modules/cloud-run-v2"
project_id = var.project_id
name = "hello"
region = var.region
containers = {
hello = {
image = "us-docker.pkg.dev/cloudrun/container/hello"
Expand All @@ -171,7 +170,7 @@ module "cloud_run" {
}
deletion_protection = false
}
# tftest modules=1 resources=1 inventory=service-beta-features.yaml e2e
# tftest modules=1 resources=1 inventory=service-direct-vpc.yaml e2e
```

## VPC Access Connector
Expand Down Expand Up @@ -561,7 +560,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; 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> |
| [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; mount_options &#61; optional&#40;list&#40;string&#41;&#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
5 changes: 3 additions & 2 deletions modules/cloud-run-v2/job.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ resource "google_cloud_run_v2_job" "job" {
dynamic "gcs" {
for_each = volumes.value.gcs == null ? [] : [""]
content {
bucket = volumes.value.gcs.bucket
read_only = volumes.value.gcs.is_read_only
bucket = volumes.value.gcs.bucket
mount_options = volumes.value.gcs.mount_options
read_only = volumes.value.gcs.is_read_only
}
}
dynamic "nfs" {
Expand Down
5 changes: 3 additions & 2 deletions modules/cloud-run-v2/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ resource "google_cloud_run_v2_service" "service" {
dynamic "gcs" {
for_each = volumes.value.gcs == null ? [] : [""]
content {
bucket = volumes.value.gcs.bucket
read_only = volumes.value.gcs.is_read_only
bucket = volumes.value.gcs.bucket
mount_options = volumes.value.gcs.mount_options
read_only = volumes.value.gcs.is_read_only
}
}
dynamic "nfs" {
Expand Down
5 changes: 3 additions & 2 deletions modules/cloud-run-v2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ variable "volumes" {
empty_dir_size = optional(string)
gcs = optional(object({
# needs revision.gen2_execution_environment
bucket = string
is_read_only = optional(bool)
bucket = string
is_read_only = optional(bool)
mount_options = optional(list(string))
}))
nfs = optional(object({
server = string
Expand Down

0 comments on commit 1cbbe62

Please sign in to comment.