Skip to content

Commit 5adad84

Browse files
authored
fix: default bucket name behavior (#42)
* fix default behaviour * fix default runtime, bump setup, devtools * regen docs
1 parent 026d833 commit 5adad84

File tree

8 files changed

+22
-15
lines changed

8 files changed

+22
-15
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.6.0
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.12.0
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Then perform the following commands on the root folder:
4747
| function\_event\_trigger\_failure\_policy\_retry | A toggle to determine if the function should be retried on failure. | bool | `"false"` | no |
4848
| function\_labels | A set of key/value label pairs to assign to the function. | map(string) | `<map>` | no |
4949
| function\_name | The name to apply to the function | string | n/a | yes |
50-
| function\_runtime | The runtime in which the function will be executed. | string | `"nodejs6"` | no |
50+
| function\_runtime | The runtime in which the function will be executed. | string | `"nodejs10"` | no |
5151
| function\_service\_account\_email | The service account to run the function as. | string | `""` | no |
5252
| function\_source\_archive\_bucket\_labels | A set of key/value label pairs to assign to the function source archive bucket. | map(string) | `<map>` | no |
5353
| function\_source\_dependent\_files | A list of any terraform created `local_file`s that the module will wait for before creating the archive. | object | `<list>` | no |

build/int.cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ tags:
3838
- 'integration'
3939
substitutions:
4040
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
41-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0'
41+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.0'

build/lint.cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ tags:
2121
- 'lint'
2222
substitutions:
2323
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
24-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.6.0'
24+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.0'

main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ module "pubsub_topic" {
5050
Cloud Function Resource Definitions
5151
*****************************************/
5252

53+
resource "random_id" "suffix" {
54+
55+
byte_length = 4
56+
}
57+
5358
module "main" {
5459
source = "terraform-google-modules/event-function/google"
5560
version = "~> 1.2"
@@ -70,7 +75,7 @@ module "main" {
7075
available_memory_mb = var.function_available_memory_mb
7176
bucket_force_destroy = var.bucket_force_destroy
7277
bucket_labels = var.function_source_archive_bucket_labels
73-
bucket_name = var.bucket_name
78+
bucket_name = var.bucket_name == "" ? "${var.project_id}-scheduled-function-${random_id.suffix.hex}" : var.bucket_name
7479
description = var.function_description
7580
environment_variables = var.function_environment_variables
7681
event_trigger_failure_policy_retry = var.function_event_trigger_failure_policy_retry

test/setup/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616

1717
module "project" {
1818
source = "terraform-google-modules/project-factory/google"
19-
version = "~> 3.0"
19+
version = "~> 9.0"
2020

21-
name = "ci-scheduled-function"
22-
random_project_id = "true"
23-
org_id = var.org_id
24-
folder_id = var.folder_id
25-
billing_account = var.billing_account
21+
name = "ci-scheduled-function"
22+
random_project_id = "true"
23+
org_id = var.org_id
24+
folder_id = var.folder_id
25+
billing_account = var.billing_account
26+
skip_gcloud_download = true
2627

2728
activate_apis = [
2829
"cloudresourcemanager.googleapis.com",
30+
"cloudbuild.googleapis.com",
2931
"storage-api.googleapis.com",
3032
"serviceusage.googleapis.com",
3133
"cloudfunctions.googleapis.com",
@@ -38,7 +40,7 @@ module "project" {
3840

3941
module "app-engine" {
4042
source = "terraform-google-modules/project-factory/google//modules/app_engine"
41-
version = "~> 3.0"
43+
version = "~> 9.0"
4244

4345
location_id = "us-central"
4446

test/setup/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ terraform {
1919
}
2020

2121
provider "google" {
22-
version = "~> 2.12.0"
22+
version = "~> 3.35.0"
2323
}
2424

2525
provider "google-beta" {
26-
version = "~> 2.12.0"
26+
version = "~> 3.35.0"
2727
}

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ variable "function_labels" {
7474

7575
variable "function_runtime" {
7676
type = string
77-
default = "nodejs6"
77+
default = "nodejs10"
7878
description = "The runtime in which the function will be executed."
7979
}
8080

0 commit comments

Comments
 (0)