Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ module "localhost_function" {
| files\_to\_exclude\_in\_source\_dir | Specify files to ignore when reading the source\_dir | `list(string)` | `[]` | no |
| ingress\_settings | The ingress settings for the function. Allowed values are ALLOW\_ALL, ALLOW\_INTERNAL\_AND\_GCLB and ALLOW\_INTERNAL\_ONLY. Changes to this field will recreate the cloud function. | `string` | `"ALLOW_ALL"` | no |
| labels | A set of key/value label pairs to assign to the Cloud Function. | `map(string)` | `{}` | no |
| log\_bucket | Log bucket | `string` | `null` | no |
| log\_object\_prefix | Log object prefix | `string` | `null` | no |
| max\_instances | The maximum number of parallel executions of the function. | `number` | `0` | no |
| name | The name to apply to any nameable resources. | `string` | n/a | yes |
| project\_id | The ID of the project to which resources will be applied. | `string` | n/a | yes |
Expand Down
19 changes: 19 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
* is creating files. See this issue for more details
* https://github.com/terraform-providers/terraform-provider-archive/issues/11
*/

locals {
logging = var.log_bucket == null ? [] : [
{
log_bucket = var.log_bucket
log_object_prefix = var.log_object_prefix
}
]
}

resource "null_resource" "dependent_files" {
triggers = {
for file in var.source_dependent_files :
Expand Down Expand Up @@ -57,6 +67,15 @@ resource "google_storage_bucket" "main" {
storage_class = "REGIONAL"
labels = var.bucket_labels
uniform_bucket_level_access = true

dynamic "logging" {
for_each = local.logging == [] ? [] : local.logging
content {
log_bucket = logging.value.log_bucket
log_object_prefix = logging.value.log_object_prefix
}
}

}

resource "google_storage_bucket_object" "main" {
Expand Down
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,16 @@ variable "vpc_connector" {
default = null
description = "The VPC Network Connector that this cloud function can connect to. It should be set up as fully-qualified URI. The format of this field is projects/*/locations/*/connectors/*."
}

variable "log_bucket" {
type = string
default = null
description = "Log bucket"
}

variable "log_object_prefix" {
type = string
default = null
description = "Log object prefix"
}