Skip to content

Commit

Permalink
feat: add support for setting build environment variables (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Sammut <[email protected]>
  • Loading branch information
grumpydude and grumpydude authored Apr 21, 2022
1 parent 78dc870 commit 022440d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module "localhost_function" {
| bucket\_force\_destroy | When deleting the GCS bucket containing the cloud function, delete all objects in the bucket first. | `bool` | `false` | no |
| bucket\_labels | A set of key/value label pairs to assign to the function source archive bucket. | `map(string)` | `{}` | no |
| bucket\_name | The name to apply to the bucket. Will default to a string of the function name. | `string` | `""` | no |
| build\_environment\_variables | A set of key/value environment variable pairs available during build time. | `map(string)` | `{}` | no |
| 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 |
| description | The description of the function. | `string` | `"Processes events."` | no |
| entry\_point | The name of a method in the function source which will be invoked when the function is executed. | `string` | n/a | yes |
Expand Down
17 changes: 9 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ resource "google_cloudfunctions_function" "main" {
}
}

labels = var.labels
runtime = var.runtime
environment_variables = var.environment_variables
source_archive_bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
source_archive_object = google_storage_bucket_object.main.name
project = var.project_id
region = var.region
service_account_email = var.service_account_email
labels = var.labels
runtime = var.runtime
environment_variables = var.environment_variables
source_archive_bucket = var.create_bucket ? google_storage_bucket.main[0].name : var.bucket_name
source_archive_object = google_storage_bucket_object.main.name
project = var.project_id
region = var.region
service_account_email = var.service_account_email
build_environment_variables = var.build_environment_variables
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ variable "log_object_prefix" {
default = null
description = "Log object prefix"
}

variable "build_environment_variables" {
type = map(string)
default = {}
description = "A set of key/value environment variable pairs available during build time."
}

0 comments on commit 022440d

Please sign in to comment.