The working cloudfunction module and example.
Add module.cloudfunction.tf to your code:-
module cloudfunction {
source ="jameswoolfenden/cloudfunction/gcp"
version = "0.0.4"
common_tags = var.common_tags
lambda = var.lambda
project = var.project
region = var.region
sourcezippath = var.sourcezippath
}See examplea.auto.tfvars for the data to drive the module.
No requirements.
| Name | Version |
|---|---|
| n/a |
No modules.
| Name | Type |
|---|---|
| google_cloudfunctions_function.lambda | resource |
| google_cloudfunctions_function_iam_member.invoker | resource |
| google_storage_bucket.code | resource |
| google_storage_bucket_object.archive | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| invoker | IAM member to grant roles/cloudfunctions.invoker (e.g. user:alice@example.com or serviceAccount:sa@project.iam.gserviceaccount.com) | string |
n/a | yes |
| kms_key_name | Full resource ID of the KMS CryptoKey to use for CMEK on the source bucket and Cloud Function | string |
n/a | yes |
| lambda | A map object that populates the majority of cloudfunction settings | map(any) |
n/a | yes |
| location | Location of the Cloud Function | string |
"eu" |
no |
| logging_bucket | Name of the GCS bucket to write access logs for the source bucket | string |
n/a | yes |
| max_instances | Maximum number of concurrent Cloud Function instances; must be >= 1 to prevent unbounded scaling | number |
100 |
no |
| project | GCP project | string |
n/a | yes |
| region | GCP region | string |
n/a | yes |
| sourcezippath | Full path to source zip file | string |
n/a | yes |
| vpc_connector | Self-link or id of the Serverless VPC Access connector for egress | string |
n/a | yes |
| vpc_connector_egress_settings | Egress settings for the VPC connector: ALL_TRAFFIC or PRIVATE_RANGES_ONLY | string |
"ALL_TRAFFIC" |
no |
| Name | Description |
|---|---|
| bucket | The google_storage_bucket resource used to store the Cloud Function source archive |
| function | The google_cloudfunctions_function resource, exposing name, https_trigger_url, and other attributes |
The Terraform resource required is:
resource "google_project_iam_custom_role" "terraform_pike" {
project = "pike-477416"
role_id = "terraform_pike"
title = "terraform_pike"
description = "A user with least privileges"
permissions = [
"cloudfunctions.functions.create",
"cloudfunctions.functions.delete",
"cloudfunctions.functions.get",
"cloudfunctions.functions.getIamPolicy",
"cloudfunctions.functions.setIamPolicy",
"cloudfunctions.functions.update",
"cloudfunctions.operations.get",
"storage.buckets.create",
"storage.buckets.delete",
"storage.buckets.get",
"storage.buckets.update",
"storage.objects.create",
"storage.objects.delete",
"storage.objects.get",
"storage.objects.list"
]
}
Check out these related projects.
- terraform-aws-codecommit - Storing ones code
Got a question?
File a GitHub issue.
Please use the issue tracker to report any bugs or file feature requests.
Copyright © 2019-2026 James Woolfenden
See LICENSE for full details.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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
https://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.
