Merge pull request #358 from lgandras/cloud-functions
Support for consistent function bundles
This commit is contained in:
commit
0e0724b833
|
@ -90,6 +90,7 @@ module "cf" {
|
|||
bundle_config = {
|
||||
source_dir = "cf"
|
||||
output_path = var.bundle_path
|
||||
excludes = null
|
||||
}
|
||||
service_account = module.service-account.email
|
||||
trigger_config = {
|
||||
|
|
|
@ -62,6 +62,7 @@ module "cf" {
|
|||
bundle_config = {
|
||||
source_dir = "cf"
|
||||
output_path = var.bundle_path
|
||||
excludes = null
|
||||
}
|
||||
# https://github.com/hashicorp/terraform-provider-archive/issues/40
|
||||
# https://issuetracker.google.com/issues/155215191
|
||||
|
|
|
@ -82,6 +82,7 @@ module "cf" {
|
|||
bundle_config = {
|
||||
source_dir = "cf"
|
||||
output_path = var.bundle_path
|
||||
excludes = null
|
||||
}
|
||||
service_account = module.service-account.email
|
||||
trigger_config = {
|
||||
|
|
|
@ -23,6 +23,7 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
}
|
||||
# tftest:skip
|
||||
|
@ -41,6 +42,7 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
trigger_config = {
|
||||
event = "google.pubsub.topic.publish"
|
||||
|
@ -64,6 +66,7 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
iam = {
|
||||
"roles/cloudfunctions.invoker" = ["allUsers"]
|
||||
|
@ -89,6 +92,7 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
}
|
||||
# tftest:skip
|
||||
|
@ -107,6 +111,7 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
service_account_create = true
|
||||
}
|
||||
|
@ -124,19 +129,39 @@ module "cf-http" {
|
|||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
service_account = local.service_account_email
|
||||
}
|
||||
# tftest:skip
|
||||
```
|
||||
|
||||
### Custom bundle config
|
||||
|
||||
In order to help prevent `archive_zip.output_md5` from changing cross platform (e.g. Cloud Build vs your local development environment), you'll have to make sure that the files included in the zip are always the same.
|
||||
|
||||
```hcl
|
||||
module "cf-http" {
|
||||
source = "./modules/cloud-function"
|
||||
project_id = "my-project"
|
||||
name = "test-cf-http"
|
||||
bucket_name = "test-cf-bundles"
|
||||
bundle_config = {
|
||||
source_dir = "my-cf-source-folder"
|
||||
output_path = "bundle.zip"
|
||||
excludes = ["__pycache__"]
|
||||
}
|
||||
}
|
||||
# tftest:skip
|
||||
```
|
||||
|
||||
<!-- BEGIN TFDOC -->
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---: |:---:|:---:|
|
||||
| bucket_name | Name of the bucket that will be used for the function code. It will be created with prefix prepended if bucket_config is not null. | <code title="">string</code> | ✓ | |
|
||||
| bundle_config | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = string })">object({...})</code> | ✓ | |
|
||||
| bundle_config | Cloud function source folder and generated zip bundle paths. Output path defaults to '/tmp/bundle.zip' if null. | <code title="object({ source_dir = string output_path = string excludes = list(string) })">object({...})</code> | ✓ | |
|
||||
| name | Name used for cloud function and associated resources. | <code title="">string</code> | ✓ | |
|
||||
| project_id | Project id used for all resources. | <code title="">string</code> | ✓ | |
|
||||
| *bucket_config* | Enable and configure auto-created bucket. Set fields to null to use defaults. | <code title="object({ location = string lifecycle_delete_age = number })">object({...})</code> | | <code title="">null</code> |
|
||||
|
|
|
@ -137,6 +137,8 @@ data "archive_file" "bundle" {
|
|||
? "/tmp/bundle.zip"
|
||||
: var.bundle_config.output_path
|
||||
)
|
||||
output_file_mode = "0666"
|
||||
excludes = var.bundle_config.excludes
|
||||
}
|
||||
|
||||
resource "google_service_account" "service_account" {
|
||||
|
|
|
@ -33,6 +33,7 @@ variable "bundle_config" {
|
|||
type = object({
|
||||
source_dir = string
|
||||
output_path = string
|
||||
excludes = list(string)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ module "function-hello" {
|
|||
bundle_config = {
|
||||
source_dir = "${path.module}/assets"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
bucket_config = {
|
||||
location = var.region
|
||||
|
|
|
@ -22,6 +22,7 @@ module "test" {
|
|||
bundle_config = {
|
||||
source_dir = "bundle"
|
||||
output_path = "bundle.zip"
|
||||
excludes = null
|
||||
}
|
||||
iam = {
|
||||
"roles/cloudfunctions.invoker" = ["allUsers"]
|
||||
|
|
Loading…
Reference in New Issue