Fix gcs mounts for cloud-run-v2, closes #2684
This commit is contained in:
committed by
Wiktor Niesiobędzki
parent
2b378f4b3a
commit
fe52a9102b
@@ -5,6 +5,7 @@ Cloud Run Services and Jobs, with support for IAM roles and Eventarc trigger cre
|
||||
<!-- BEGIN TOC -->
|
||||
- [IAM and environment variables](#iam-and-environment-variables)
|
||||
- [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)
|
||||
- [VPC Access Connector](#vpc-access-connector)
|
||||
@@ -84,6 +85,34 @@ module "cloud_run" {
|
||||
# tftest modules=2 resources=4 fixtures=fixtures/secret-credentials.tf inventory=service-volume-secretes.yaml e2e
|
||||
```
|
||||
|
||||
## Mounting GCS buckets
|
||||
|
||||
```hcl
|
||||
module "cloud_run" {
|
||||
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"
|
||||
volume_mounts = {
|
||||
bucket = "/bucket"
|
||||
}
|
||||
}
|
||||
}
|
||||
volumes = {
|
||||
bucket = {
|
||||
gcs = {
|
||||
bucket = var.bucket
|
||||
is_read_only = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest inventory=gcs-mount.yaml e2e
|
||||
```
|
||||
|
||||
## Connecting to Cloud SQL database
|
||||
|
||||
```hcl
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2023 Google LLC
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -208,16 +208,16 @@ resource "google_cloud_run_v2_service" "service" {
|
||||
dynamic "gcs" {
|
||||
for_each = volumes.value.gcs == null ? [] : [""]
|
||||
content {
|
||||
bucket = volumes.value.bucket
|
||||
read_only = volumes.value.is_read_only
|
||||
bucket = volumes.value.gcs.bucket
|
||||
read_only = volumes.value.gcs.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
|
||||
server = volumes.value.nfs.server
|
||||
path = volumes.value.nfs.path
|
||||
read_only = volumes.value.nfs.is_read_only
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
tests/modules/cloud_run_v2/examples/gcs-mount.yaml
Normal file
40
tests/modules/cloud_run_v2/examples/gcs-mount.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
values:
|
||||
module.cloud_run.google_cloud_run_v2_service.service[0]:
|
||||
location: europe-west8
|
||||
name: hello
|
||||
project: project-id
|
||||
template:
|
||||
- containers:
|
||||
- image: us-docker.pkg.dev/cloudrun/container/hello
|
||||
name: hello
|
||||
volume_mounts:
|
||||
- mount_path: /bucket
|
||||
name: bucket
|
||||
execution_environment: EXECUTION_ENVIRONMENT_GEN1
|
||||
volumes:
|
||||
- cloud_sql_instance: []
|
||||
empty_dir: []
|
||||
gcs:
|
||||
- bucket: bucket
|
||||
read_only: false
|
||||
name: bucket
|
||||
nfs: []
|
||||
secret: []
|
||||
|
||||
counts:
|
||||
google_cloud_run_v2_service: 1
|
||||
modules: 1
|
||||
Reference in New Issue
Block a user