Merge branch 'master' into bruzz/nva-firewall-mgmt
This commit is contained in:
commit
dfa1fce274
|
@ -218,6 +218,35 @@ module "cf-http" {
|
|||
}
|
||||
}
|
||||
# tftest modules=1 resources=2
|
||||
```
|
||||
|
||||
### Multiple Cloud Functions within project
|
||||
|
||||
When deploying multiple functions do not reuse `bundle_config.output_path` between instances as the result is undefined. Default `output_path` creates file in `/tmp` folder using project Id and function name to avoid name conflicts.
|
||||
|
||||
```hcl
|
||||
module "cf-http-one" {
|
||||
source = "./fabric/modules/cloud-function"
|
||||
project_id = "my-project"
|
||||
name = "test-cf-http-one"
|
||||
bucket_name = "test-cf-bundles"
|
||||
bundle_config = {
|
||||
source_dir = "fabric/assets"
|
||||
}
|
||||
}
|
||||
|
||||
module "cf-http-two" {
|
||||
source = "./fabric/modules/cloud-function"
|
||||
project_id = "my-project"
|
||||
name = "test-cf-http-two"
|
||||
bucket_name = "test-cf-bundles"
|
||||
bundle_config = {
|
||||
source_dir = "fabric/assets"
|
||||
}
|
||||
}
|
||||
# tftest modules=2 resources=4 inventory=multiple_functions.yaml
|
||||
|
||||
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
@ -226,7 +255,7 @@ module "cf-http" {
|
|||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [bucket_name](variables.tf#L26) | Name of the bucket that will be used for the function code. It will be created with prefix prepended if bucket_config is not null. | <code>string</code> | ✓ | |
|
||||
| [bundle_config](variables.tf#L37) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = optional(string, "/tmp/bundle.zip") excludes = optional(list(string)) })">object({…})</code> | ✓ | |
|
||||
| [bundle_config](variables.tf#L37) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = optional(string) excludes = optional(list(string)) })">object({…})</code> | ✓ | |
|
||||
| [name](variables.tf#L94) | Name used for cloud function and associated resources. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L109) | Project id used for all resources. | <code>string</code> | ✓ | |
|
||||
| [bucket_config](variables.tf#L17) | Enable and configure auto-created bucket. Set fields to null to use defaults. | <code title="object({ location = optional(string) lifecycle_delete_age_days = optional(number) })">object({…})</code> | | <code>null</code> |
|
||||
|
|
|
@ -267,8 +267,8 @@ resource "google_storage_bucket_object" "bundle" {
|
|||
data "archive_file" "bundle" {
|
||||
type = "zip"
|
||||
source_dir = var.bundle_config.source_dir
|
||||
output_path = var.bundle_config.output_path
|
||||
output_file_mode = "0666"
|
||||
output_path = coalesce(var.bundle_config.output_path, "/tmp/bundle-${var.project_id}-${var.name}.zip")
|
||||
output_file_mode = "0644"
|
||||
excludes = var.bundle_config.excludes
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ variable "bundle_config" {
|
|||
description = "Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null."
|
||||
type = object({
|
||||
source_dir = string
|
||||
output_path = optional(string, "/tmp/bundle.zip")
|
||||
output_path = optional(string)
|
||||
excludes = optional(list(string))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright 2023 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.cf-http-one.google_storage_bucket_object.bundle:
|
||||
source: /tmp/bundle-my-project-test-cf-http-one.zip
|
||||
module.cf-http-two.google_storage_bucket_object.bundle:
|
||||
source: /tmp/bundle-my-project-test-cf-http-two.zip
|
||||
|
||||
counts:
|
||||
google_cloudfunctions_function: 2
|
||||
google_storage_bucket_object: 2
|
||||
modules: 2
|
||||
resources: 4
|
Loading…
Reference in New Issue