Skip to content

Commit 564e92e

Browse files
authored
fix!: Making Cloud Functions ADC Compliant (#194)
1 parent d1dc412 commit 564e92e

28 files changed

Lines changed: 1583 additions & 1163 deletions

File tree

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.24
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.25
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

@@ -77,9 +77,10 @@ docker_test_lint:
7777
.PHONY: docker_generate_docs
7878
docker_generate_docs:
7979
docker run --rm -it \
80+
-e ENABLE_BPMETADATA=1 \
8081
-v "$(CURDIR)":/workspace \
8182
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
82-
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
83+
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display'
8384

8485
# Alias for backwards compatibility
8586
.PHONY: generate_docs

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "cloud_functions2" {
3131
# Required variables
3232
function_name = "<FUNCTION_NAME>"
3333
project_id = "<PROJECT_ID>"
34-
function_location = "<LOCATION>"
34+
location = "<LOCATION>"
3535
runtime = "<RUNTIME>"
3636
entrypoint = "<ENTRYPOINT>"
3737
storage_source = {
@@ -56,9 +56,10 @@ Functional examples are included in the
5656
| docker\_repository | User managed repository created in Artifact Registry optionally with a customer managed encryption key. | `string` | `null` | no |
5757
| entrypoint | The name of the function (as defined in source code) that will be executed. Defaults to the resource name suffix, if not specified | `string` | n/a | yes |
5858
| event\_trigger | Event triggers for the function | <pre>object({<br> trigger_region = optional(string)<br> event_type = string<br> service_account_email = string<br> pubsub_topic = optional(string)<br> retry_policy = string<br> event_filters = optional(set(object({<br> attribute = string<br> attribute_value = string<br> operator = optional(string)<br> })))<br> })</pre> | `null` | no |
59-
| function\_location | The location of this cloud function | `string` | n/a | yes |
59+
| function\_location | DEPRECATED: Please use the 'location' variable instead. This will be removed in a future version. | `string` | `null` | no |
6060
| function\_name | A user-defined name of the function | `string` | n/a | yes |
6161
| labels | A set of key/value label pairs associated with this Cloud Function | `map(string)` | `null` | no |
62+
| location | The location of this cloud function | `string` | n/a | yes |
6263
| members | Cloud Function Invoker and Developer roles for Users/SAs. Key names must be developers and/or invokers | `map(list(string))` | `{}` | no |
6364
| project\_id | Project ID to create Cloud Function | `string` | n/a | yes |
6465
| repo\_source | Get the source from this location in a Cloud Source Repository | <pre>object({<br> project_id = optional(string)<br> repo_name = string<br> branch_name = string<br> dir = optional(string)<br> tag_name = optional(string)<br> commit_sha = optional(string)<br> invert_regex = optional(bool, false)<br> })</pre> | `null` | no |

examples/cloud_function2_gcs_source/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ This example illustrates how to use the `cloud-functions` module.
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| function\_location | The location of this cloud function | `string` | `"us-central1"` | no |
10+
| location | The location of this cloud function | `string` | `"us-central1"` | no |
1111
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |
1212

1313
## Outputs
1414

1515
| Name | Description |
1616
|------|-------------|
17-
| function\_location | Location of the Cloud Function (Gen 2) |
1817
| function\_name | Name of the Cloud Function (Gen 2) |
1918
| function\_uri | URI of the Cloud Function (Gen 2) |
19+
| location | Location of the Cloud Function (Gen 2) |
2020
| project\_id | The project ID |
2121

2222
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/cloud_function2_gcs_source/main.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ resource "google_storage_bucket_object" "function-source" {
2828
}
2929

3030
module "cloud_functions2" {
31-
source = "GoogleCloudPlatform/cloud-functions/google"
32-
version = "~> 0.6"
31+
source = "../../"
3332

34-
project_id = var.project_id
35-
function_name = "function2-gcs-source-py"
36-
function_location = var.function_location
37-
runtime = "python38"
38-
entrypoint = "hello_http"
33+
project_id = var.project_id
34+
function_name = "function2-gcs-source-py"
35+
location = var.location
36+
runtime = "python310"
37+
entrypoint = "hello_http"
3938
storage_source = {
4039
bucket = google_storage_bucket.bucket.name
4140
object = google_storage_bucket_object.function-source.name

examples/cloud_function2_gcs_source/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ output "function_name" {
2424
value = module.cloud_functions2.function_name
2525
}
2626

27-
output "function_location" {
27+
output "location" {
2828
description = "Location of the Cloud Function (Gen 2)"
29-
value = var.function_location
29+
value = var.location
3030
}
3131

3232
output "project_id" {

examples/cloud_function2_gcs_source/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variable "project_id" {
1919
type = string
2020
}
2121

22-
variable "function_location" {
22+
variable "location" {
2323
description = "The location of this cloud function"
2424
type = string
2525
default = "us-central1"

examples/cloud_function2_pubsub_trigger/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ This example illustrates how to use the `cloud-functions` module.
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| function\_location | The location of this cloud function | `string` | `"us-central1"` | no |
10+
| location | The location of this cloud function | `string` | `"us-central1"` | no |
1111
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |
1212

1313
## Outputs
1414

1515
| Name | Description |
1616
|------|-------------|
17-
| function\_location | Location of the Cloud Function (Gen 2) |
1817
| function\_name | Name of the Cloud Function (Gen 2) |
1918
| function\_uri | URI of the Cloud Function (Gen 2) |
19+
| location | Location of the Cloud Function (Gen 2) |
2020
| project\_id | The project ID |
2121
| pubsub\_topic | Name of the PubSub Topic |
2222

examples/cloud_function2_pubsub_trigger/main.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ module "pubsub" {
3636
}
3737

3838
module "cloud_functions2" {
39-
source = "GoogleCloudPlatform/cloud-functions/google"
40-
version = "~> 0.6"
39+
source = "../../"
4140

42-
project_id = var.project_id
43-
function_name = "function2-pubsub-trigger-py"
44-
function_location = var.function_location
45-
runtime = "python38"
46-
entrypoint = "hello_http"
41+
project_id = var.project_id
42+
function_name = "function2-pubsub-trigger-py"
43+
location = var.location
44+
runtime = "python310"
45+
entrypoint = "hello_http"
4746
storage_source = {
4847
bucket = google_storage_bucket.bucket.name
4948
object = google_storage_bucket_object.function-source.name

examples/cloud_function2_pubsub_trigger/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ output "function_name" {
2424
value = module.cloud_functions2.function_name
2525
}
2626

27-
output "function_location" {
27+
output "location" {
2828
description = "Location of the Cloud Function (Gen 2)"
29-
value = var.function_location
29+
value = var.location
3030
}
3131

3232
output "pubsub_topic" {

examples/cloud_function2_pubsub_trigger/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variable "project_id" {
1919
type = string
2020
}
2121

22-
variable "function_location" {
22+
variable "location" {
2323
description = "The location of this cloud function"
2424
type = string
2525
default = "us-central1"

0 commit comments

Comments
 (0)