Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default region for Cloud Function and Cloud Run #2004

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module "service-account" {
module "cf" {
source = "../../../modules/cloud-function-v1"
project_id = module.project.project_id
region = var.region
name = var.name
bucket_name = "${var.name}-${random_pet.random.id}"
bucket_config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ module "test-vm" {
module "function-hello" {
source = "../../../modules/cloud-function-v1"
project_id = module.project.project_id
region = var.region
name = var.name
bucket_name = "${var.name}-tf-cf-deploy"
ingress_settings = "ALLOW_INTERNAL_ONLY"
Expand Down
27 changes: 19 additions & 8 deletions modules/cloud-function-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This deploys a Cloud Function with an HTTP endpoint, using a pre-existing GCS bu
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = var.project_id
region = "europe-west1"
name = "test-cf-http"
bucket_name = var.bucket
bundle_config = {
Expand All @@ -52,6 +53,7 @@ Other trigger types other than HTTP are configured via the `trigger_config` vari
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -74,6 +76,7 @@ To allow anonymous access to the function, grant the `roles/cloudfunctions.invok
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -95,6 +98,7 @@ You can have the module auto-create the GCS bucket used for deployment via the `
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
prefix = "my-prefix"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
Expand All @@ -116,6 +120,7 @@ To use a custom service account managed by the module, set `service_account_crea
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -133,6 +138,7 @@ To use an externally managed service account, pass its email in `service_account
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -152,6 +158,7 @@ In order to help prevent `archive_zip.output_md5` from changing cross platform (
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -171,6 +178,7 @@ This deploys a Cloud Function with an HTTP endpoint, using a pre-existing GCS bu
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
build_worker_pool = "projects/my-project/locations/europe-west1/workerPools/my_build_worker_pool"
Expand All @@ -190,6 +198,7 @@ When deploying multiple functions do not reuse `bundle_config.output_path` betwe
module "cf-http-one" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http-one"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -200,6 +209,7 @@ module "cf-http-one" {
module "cf-http-two" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http-two"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -218,6 +228,7 @@ This provides the latest value of the secret `var_secret` as `VARIABLE_SECRET` e
module "cf-http" {
source = "./fabric/modules/cloud-function-v1"
project_id = "my-project"
region = "europe-west1"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand Down Expand Up @@ -256,6 +267,7 @@ module "cf-http" {
| [bundle_config](variables.tf#L38) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object&#40;&#123;&#10; source_dir &#61; string&#10; output_path &#61; optional&#40;string&#41;&#10; excludes &#61; optional&#40;list&#40;string&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [name](variables.tf#L97) | Name used for cloud function and associated resources. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L112) | Project id used for all resources. | <code>string</code> | ✓ | |
| [region](variables.tf#L117) | Region 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&#40;&#123;&#10; location &#61; optional&#40;string&#41;&#10; lifecycle_delete_age_days &#61; optional&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [build_worker_pool](variables.tf#L32) | Build worker pool, in projects/<PROJECT-ID>/locations/<REGION>/workerPools/<POOL_NAME> format. | <code>string</code> | | <code>null</code> |
| [description](variables.tf#L47) | Optional description. | <code>string</code> | | <code>&#34;Terraform managed.&#34;</code> |
Expand All @@ -265,13 +277,12 @@ module "cf-http" {
| [ingress_settings](variables.tf#L85) | Control traffic that reaches the cloud function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY . | <code>string</code> | | <code>null</code> |
| [labels](variables.tf#L91) | Resource labels. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [prefix](variables.tf#L102) | Optional prefix used for resource names. | <code>string</code> | | <code>null</code> |
| [region](variables.tf#L117) | Region used for all resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> |
| [secrets](variables.tf#L123) | Secret Manager secrets. Key is the variable name or mountpoint, volume versions are in version:path format. | <code title="map&#40;object&#40;&#123;&#10; is_volume &#61; bool&#10; project_id &#61; number&#10; secret &#61; string&#10; versions &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [service_account](variables.tf#L135) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L141) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [trigger_config](variables.tf#L147) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object&#40;&#123;&#10; event &#61; string&#10; resource &#61; string&#10; retry &#61; optional&#40;bool&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector](variables.tf#L157) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector_config](variables.tf#L167) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [secrets](variables.tf#L122) | Secret Manager secrets. Key is the variable name or mountpoint, volume versions are in version:path format. | <code title="map&#40;object&#40;&#123;&#10; is_volume &#61; bool&#10; project_id &#61; number&#10; secret &#61; string&#10; versions &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [service_account](variables.tf#L134) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L140) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [trigger_config](variables.tf#L146) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object&#40;&#123;&#10; event &#61; string&#10; resource &#61; string&#10; retry &#61; optional&#40;bool&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector](variables.tf#L156) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector_config](variables.tf#L166) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand All @@ -286,4 +297,4 @@ module "cf-http" {
| [service_account_email](outputs.tf#L49) | Service account email. | |
| [service_account_iam_email](outputs.tf#L54) | Service account email. | |
| [vpc_connector](outputs.tf#L62) | VPC connector resource if created. | |
<!-- END TFDOC -->
<!-- END TFDOC -->
3 changes: 1 addition & 2 deletions modules/cloud-function-v1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ variable "project_id" {
variable "region" {
description = "Region used for all resources."
type = string
default = "europe-west1"
}

variable "secrets" {
Expand Down Expand Up @@ -171,4 +170,4 @@ variable "vpc_connector_config" {
network = string
})
default = null
}
}
25 changes: 18 additions & 7 deletions modules/cloud-function-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This deploys a Cloud Function with an HTTP endpoint, using a pre-existing GCS bu
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand Down Expand Up @@ -63,6 +64,7 @@ module "trigger-service-account" {
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -89,6 +91,7 @@ To allow anonymous access to the function, grant the `roles/run.invoker` role to
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -110,6 +113,7 @@ You can have the module auto-create the GCS bucket used for deployment via the `
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
prefix = "my-prefix"
name = "test-cf-http"
bucket_name = "test-cf-bundles"
Expand All @@ -131,6 +135,7 @@ To use a custom service account managed by the module, set `service_account_crea
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -148,6 +153,7 @@ To use an externally managed service account, pass its email in `service_account
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -167,6 +173,7 @@ In order to help prevent `archive_zip.output_md5` from changing cross platform (
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -186,6 +193,7 @@ This deploys a Cloud Function with an HTTP endpoint, using a pre-existing GCS bu
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
build_worker_pool = "projects/my-project/locations/europe-west1/workerPools/my_build_worker_pool"
Expand All @@ -205,6 +213,7 @@ When deploying multiple functions do not reuse `bundle_config.output_path` betwe
module "cf-http-one" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http-one"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -215,6 +224,7 @@ module "cf-http-one" {
module "cf-http-two" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http-two"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand All @@ -233,6 +243,7 @@ This provides the latest value of the secret `var_secret` as `VARIABLE_SECRET` e
module "cf-http" {
source = "./fabric/modules/cloud-function-v2"
project_id = "my-project"
region = var.region
name = "test-cf-http"
bucket_name = "test-cf-bundles"
bundle_config = {
Expand Down Expand Up @@ -272,6 +283,7 @@ module "cf-http" {
| [bundle_config](variables.tf#L38) | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object&#40;&#123;&#10; source_dir &#61; string&#10; output_path &#61; optional&#40;string&#41;&#10; excludes &#61; optional&#40;list&#40;string&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | |
| [name](variables.tf#L103) | Name used for cloud function and associated resources. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L118) | Project id used for all resources. | <code>string</code> | ✓ | |
| [region](variables.tf#L123) | Region 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&#40;&#123;&#10; location &#61; optional&#40;string&#41;&#10; lifecycle_delete_age_days &#61; optional&#40;number&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [build_worker_pool](variables.tf#L32) | Build worker pool, in projects/<PROJECT-ID>/locations/<REGION>/workerPools/<POOL_NAME> format. | <code>string</code> | | <code>null</code> |
| [description](variables.tf#L47) | Optional description. | <code>string</code> | | <code>&#34;Terraform managed.&#34;</code> |
Expand All @@ -282,13 +294,12 @@ module "cf-http" {
| [ingress_settings](variables.tf#L91) | Control traffic that reaches the cloud function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY . | <code>string</code> | | <code>null</code> |
| [labels](variables.tf#L97) | Resource labels. | <code>map&#40;string&#41;</code> | | <code>&#123;&#125;</code> |
| [prefix](variables.tf#L108) | Optional prefix used for resource names. | <code>string</code> | | <code>null</code> |
| [region](variables.tf#L123) | Region used for all resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> |
| [secrets](variables.tf#L129) | Secret Manager secrets. Key is the variable name or mountpoint, volume versions are in version:path format. | <code title="map&#40;object&#40;&#123;&#10; is_volume &#61; bool&#10; project_id &#61; number&#10; secret &#61; string&#10; versions &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [service_account](variables.tf#L141) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L147) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [trigger_config](variables.tf#L153) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object&#40;&#123;&#10; event_type &#61; string&#10; pubsub_topic &#61; optional&#40;string&#41;&#10; region &#61; optional&#40;string&#41;&#10; event_filters &#61; optional&#40;list&#40;object&#40;&#123;&#10; attribute &#61; string&#10; value &#61; string&#10; operator &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;, &#91;&#93;&#41;&#10; service_account_email &#61; optional&#40;string&#41;&#10; service_account_create &#61; optional&#40;bool, false&#41;&#10; retry_policy &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector](variables.tf#L171) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector_config](variables.tf#L181) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [secrets](variables.tf#L128) | Secret Manager secrets. Key is the variable name or mountpoint, volume versions are in version:path format. | <code title="map&#40;object&#40;&#123;&#10; is_volume &#61; bool&#10; project_id &#61; number&#10; secret &#61; string&#10; versions &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [service_account](variables.tf#L140) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
| [service_account_create](variables.tf#L146) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
| [trigger_config](variables.tf#L152) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object&#40;&#123;&#10; event_type &#61; string&#10; pubsub_topic &#61; optional&#40;string&#41;&#10; region &#61; optional&#40;string&#41;&#10; event_filters &#61; optional&#40;list&#40;object&#40;&#123;&#10; attribute &#61; string&#10; value &#61; string&#10; operator &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;, &#91;&#93;&#41;&#10; service_account_email &#61; optional&#40;string&#41;&#10; service_account_create &#61; optional&#40;bool, false&#41;&#10; retry_policy &#61; optional&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector](variables.tf#L170) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [vpc_connector_config](variables.tf#L180) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
Loading