Skip to content

Commit 022440d

Browse files
authored
feat: add support for setting build environment variables (#89)
Co-authored-by: Andrew Sammut <[email protected]>
1 parent 78dc870 commit 022440d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module "localhost_function" {
5757
| bucket\_force\_destroy | When deleting the GCS bucket containing the cloud function, delete all objects in the bucket first. | `bool` | `false` | no |
5858
| bucket\_labels | A set of key/value label pairs to assign to the function source archive bucket. | `map(string)` | `{}` | no |
5959
| bucket\_name | The name to apply to the bucket. Will default to a string of the function name. | `string` | `""` | no |
60+
| build\_environment\_variables | A set of key/value environment variable pairs available during build time. | `map(string)` | `{}` | no |
6061
| create\_bucket | Whether to create a new bucket or use an existing one. If false, `bucket_name` should reference the name of the alternate bucket to use. | `bool` | `true` | no |
6162
| description | The description of the function. | `string` | `"Processes events."` | no |
6263
| entry\_point | The name of a method in the function source which will be invoked when the function is executed. | `string` | n/a | yes |

main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ resource "google_cloudfunctions_function" "main" {
130130
}
131131
}
132132

133-
labels = var.labels
134-
runtime = var.runtime
135-
environment_variables = var.environment_variables
136-
source_archive_bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
137-
source_archive_object = google_storage_bucket_object.main.name
138-
project = var.project_id
139-
region = var.region
140-
service_account_email = var.service_account_email
133+
labels = var.labels
134+
runtime = var.runtime
135+
environment_variables = var.environment_variables
136+
source_archive_bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
137+
source_archive_object = google_storage_bucket_object.main.name
138+
project = var.project_id
139+
region = var.region
140+
service_account_email = var.service_account_email
141+
build_environment_variables = var.build_environment_variables
141142
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,9 @@ variable "log_object_prefix" {
178178
default = null
179179
description = "Log object prefix"
180180
}
181+
182+
variable "build_environment_variables" {
183+
type = map(string)
184+
default = {}
185+
description = "A set of key/value environment variable pairs available during build time."
186+
}

0 commit comments

Comments
 (0)