Skip to content

Commit 3bb8cba

Browse files
cloud-foundation-botbharathkkbJamesDuncanNzmorgante
authored
feat!: add Terraform 0.13 constraint and module attribution (#50)
* feat!: add Terraform 0.13 constraint and module attribution * fmt * Bump versions and fix IAM for testing * regen docs Co-authored-by: bharathkkb <[email protected]> Co-authored-by: James Duncan <[email protected]> Co-authored-by: Morgante Pell <[email protected]>
1 parent f9e3841 commit 3bb8cba

File tree

14 files changed

+122
-75
lines changed

14 files changed

+122
-75
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.12.0
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

README.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
This modules makes it easy to set up a scheduled job to trigger events/run functions.
44

55
## Compatibility
6-
7-
This module is meant for use with Terraform 0.12. If you haven't
8-
[upgraded](https://www.terraform.io/upgrade-guides/0-12.html) and need a Terraform 0.11.x-compatible
9-
version of this module, the last released version intended for Terraform 0.11.x
10-
is [v0.4.1](https://registry.terraform.io/modules/terraform-google-modules/scheduled-function/google/0.4.1).
6+
This module is meant for use with Terraform 0.13. If you haven't
7+
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
8+
0.12.x-compatible version of this module, the last released version
9+
intended for Terraform 0.12.x is [v1.5.1](https://registry.terraform.io/modules/terraform-google-modules/-scheduled-function/google/v1.5.1).
1110

1211
## Usage
1312
You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:
@@ -37,32 +36,32 @@ Then perform the following commands on the root folder:
3736
## Inputs
3837

3938
| Name | Description | Type | Default | Required |
40-
|------|-------------|:----:|:-----:|:-----:|
41-
| bucket\_force\_destroy | When deleting the GCS bucket containing the cloud function, delete all objects in the bucket first. | bool | `"true"` | no |
42-
| bucket\_name | The name to apply to the bucket. Will default to a string of <project-id>-scheduled-function-XXXX> with XXXX being random characters. | string | `""` | no |
43-
| function\_available\_memory\_mb | The amount of memory in megabytes allotted for the function to use. | number | `"256"` | no |
44-
| function\_description | The description of the function. | string | `"Processes log export events provided through a Pub/Sub topic subscription."` | no |
45-
| function\_entry\_point | The name of a method in the function source which will be invoked when the function is executed. | string | n/a | yes |
46-
| function\_environment\_variables | A set of key/value environment variable pairs to assign to the function. | map(string) | `<map>` | no |
47-
| function\_event\_trigger\_failure\_policy\_retry | A toggle to determine if the function should be retried on failure. | bool | `"false"` | no |
48-
| function\_labels | A set of key/value label pairs to assign to the function. | map(string) | `<map>` | no |
49-
| 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 | `"nodejs10"` | no |
51-
| function\_service\_account\_email | The service account to run the function as. | string | `""` | no |
52-
| function\_source\_archive\_bucket\_labels | A set of key/value label pairs to assign to the function source archive bucket. | map(string) | `<map>` | no |
53-
| 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 |
54-
| function\_source\_directory | The contents of this directory will be archived and used as the function source. | string | n/a | yes |
55-
| function\_timeout\_s | The amount of time in seconds allotted for the execution of the function. | number | `"60"` | no |
56-
| grant\_token\_creator | Specify true if you want to add token creator role to the default Pub/Sub SA | bool | `"false"` | no |
57-
| job\_description | Addition text to describe the job | string | `""` | no |
58-
| job\_name | The name of the scheduled job to run | string | `"null"` | no |
59-
| job\_schedule | The job frequency, in cron syntax | string | `"*/2 * * * *"` | no |
60-
| message\_data | The data to send in the topic message. | string | `"dGVzdA=="` | no |
61-
| project\_id | The ID of the project where the resources will be created | string | n/a | yes |
62-
| region | The region in which resources will be applied. | string | n/a | yes |
63-
| scheduler\_job | An existing Cloud Scheduler job instance | object | `"null"` | no |
64-
| time\_zone | The timezone to use in scheduler | string | `"Etc/UTC"` | no |
65-
| topic\_name | Name of pubsub topic connecting the scheduled job and the function | string | `"test-topic"` | no |
39+
|------|-------------|------|---------|:--------:|
40+
| bucket\_force\_destroy | When deleting the GCS bucket containing the cloud function, delete all objects in the bucket first. | `bool` | `true` | no |
41+
| bucket\_name | The name to apply to the bucket. Will default to a string of <project-id>-scheduled-function-XXXX> with XXXX being random characters. | `string` | `""` | no |
42+
| function\_available\_memory\_mb | The amount of memory in megabytes allotted for the function to use. | `number` | `256` | no |
43+
| function\_description | The description of the function. | `string` | `"Processes log export events provided through a Pub/Sub topic subscription."` | no |
44+
| function\_entry\_point | The name of a method in the function source which will be invoked when the function is executed. | `string` | n/a | yes |
45+
| function\_environment\_variables | A set of key/value environment variable pairs to assign to the function. | `map(string)` | `{}` | no |
46+
| function\_event\_trigger\_failure\_policy\_retry | A toggle to determine if the function should be retried on failure. | `bool` | `false` | no |
47+
| function\_labels | A set of key/value label pairs to assign to the function. | `map(string)` | `{}` | no |
48+
| function\_name | The name to apply to the function | `string` | n/a | yes |
49+
| function\_runtime | The runtime in which the function will be executed. | `string` | `"nodejs10"` | no |
50+
| function\_service\_account\_email | The service account to run the function as. | `string` | `""` | no |
51+
| function\_source\_archive\_bucket\_labels | A set of key/value label pairs to assign to the function source archive bucket. | `map(string)` | `{}` | no |
52+
| function\_source\_dependent\_files | A list of any terraform created `local_file`s that the module will wait for before creating the archive. | <pre>list(object({<br> filename = string<br> id = string<br> }))</pre> | `[]` | no |
53+
| function\_source\_directory | The contents of this directory will be archived and used as the function source. | `string` | n/a | yes |
54+
| function\_timeout\_s | The amount of time in seconds allotted for the execution of the function. | `number` | `60` | no |
55+
| grant\_token\_creator | Specify true if you want to add token creator role to the default Pub/Sub SA | `bool` | `false` | no |
56+
| job\_description | Addition text to describe the job | `string` | `""` | no |
57+
| job\_name | The name of the scheduled job to run | `string` | `null` | no |
58+
| job\_schedule | The job frequency, in cron syntax | `string` | `"*/2 * * * *"` | no |
59+
| message\_data | The data to send in the topic message. | `string` | `"dGVzdA=="` | no |
60+
| project\_id | The ID of the project where the resources will be created | `string` | n/a | yes |
61+
| region | The region in which resources will be applied. | `string` | n/a | yes |
62+
| scheduler\_job | An existing Cloud Scheduler job instance | `object({ name = string })` | `null` | no |
63+
| time\_zone | The timezone to use in scheduler | `string` | `"Etc/UTC"` | no |
64+
| topic\_name | Name of pubsub topic connecting the scheduled job and the function | `string` | `"test-topic"` | no |
6665

6766
## Outputs
6867

@@ -82,7 +81,7 @@ These sections describe requirements for using this module.
8281

8382
The following dependencies must be available:
8483

85-
- [Terraform][terraform] v0.12
84+
- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
8685
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v2.14
8786

8887
### App Engine

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.12.0'
41+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'

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.12.0'
24+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'

examples/logs-slack-alerts/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ If not using the default App Engine default service account (PROJECT_ID@appspot.
1616
## Inputs
1717

1818
| Name | Description | Type | Default | Required |
19-
|------|-------------|:----:|:-----:|:-----:|
20-
| audit\_log\_table | BigQuery Table where logs are sent | string | n/a | yes |
21-
| dataset\_name | BigQuery Dataset where logs are sent | string | n/a | yes |
22-
| error\_message\_column | BigQuery Column in audit log table representing logging error | string | n/a | yes |
23-
| job\_schedule | The cron schedule for triggering the cloud function | string | `"55 * * * *"` | no |
24-
| project\_id | The project ID to host the network in | string | n/a | yes |
25-
| region | The region the project is in (App Engine specific) | string | `"us-central1"` | no |
26-
| slack\_webhook | Slack webhook to send alerts | string | n/a | yes |
27-
| time\_column | BigQuery Column in audit log table representing logging time | string | n/a | yes |
19+
|------|-------------|------|---------|:--------:|
20+
| audit\_log\_table | BigQuery Table where logs are sent | `string` | n/a | yes |
21+
| dataset\_name | BigQuery Dataset where logs are sent | `string` | n/a | yes |
22+
| error\_message\_column | BigQuery Column in audit log table representing logging error | `string` | n/a | yes |
23+
| job\_schedule | The cron schedule for triggering the cloud function | `string` | `"55 * * * *"` | no |
24+
| project\_id | The project ID to host the network in | `string` | n/a | yes |
25+
| region | The region the project is in (App Engine specific) | `string` | `"us-central1"` | no |
26+
| slack\_webhook | Slack webhook to send alerts | `string` | n/a | yes |
27+
| time\_column | BigQuery Column in audit log table representing logging time | `string` | n/a | yes |
28+
29+
## Outputs
30+
31+
No output.
2832

2933
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/pubsub_scheduled/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ More information is in the [root readme](../../README.md#app-engine).
99
## Inputs
1010

1111
| Name | Description | Type | Default | Required |
12-
|------|-------------|:----:|:-----:|:-----:|
13-
| project\_id | The project ID to host the network in | string | n/a | yes |
14-
| region | The region the project is in (App Engine specific) | string | `"us-central1"` | no |
12+
|------|-------------|------|---------|:--------:|
13+
| project\_id | The project ID to host the network in | `string` | n/a | yes |
14+
| region | The region the project is in (App Engine specific) | `string` | `"us-central1"` | no |
1515

1616
## Outputs
1717

examples/pubsub_scheduled_multiple/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ More information is in the [root readme](../../README.md#app-engine).
99
## Inputs
1010

1111
| Name | Description | Type | Default | Required |
12-
|------|-------------|:----:|:-----:|:-----:|
13-
| project\_id | The project ID to host the network in | string | `"flask-app-254610"` | no |
14-
| region | The region the project is in (App Engine specific) | string | `"us-central1"` | no |
12+
|------|-------------|------|---------|:--------:|
13+
| project\_id | The project ID to host the network in | `string` | `"flask-app-254610"` | no |
14+
| region | The region the project is in (App Engine specific) | `string` | `"us-central1"` | no |
1515

1616
## Outputs
1717

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ resource "random_id" "suffix" {
5858

5959
module "main" {
6060
source = "terraform-google-modules/event-function/google"
61-
version = "~> 1.2"
61+
version = "~> 1.6"
6262

6363
entry_point = var.function_entry_point
6464
event_trigger = {

modules/project_cleanup/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ The following services must be enabled on the project housing the cleanup functi
2020
## Inputs
2121

2222
| Name | Description | Type | Default | Required |
23-
|------|-------------|:----:|:-----:|:-----:|
24-
| function\_timeout\_s | The amount of time in seconds allotted for the execution of the function. | number | `"500"` | no |
25-
| job\_schedule | Cleaner function run frequency, in cron syntax | string | `"*/5 * * * *"` | no |
26-
| max\_project\_age\_in\_hours | The maximum number of hours that a GCP project, selected by `target_tag_name` and `target_tag_value`, can exist | number | `"6"` | no |
27-
| organization\_id | The organization ID whose projects to clean up | string | n/a | yes |
28-
| project\_id | The project ID to host the scheduled function in | string | n/a | yes |
29-
| region | The region the project is in (App Engine specific) | string | n/a | yes |
30-
| target\_excluded\_labels | Map of project lablels that won't be deleted. | map(string) | `<map>` | no |
31-
| target\_folder\_id | Folder ID to delete all projects under. | string | `""` | no |
32-
| target\_included\_labels | Map of project lablels that will be deleted. | map(string) | `<map>` | no |
33-
| target\_tag\_name | The name of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | string | `""` | no |
34-
| target\_tag\_value | The value of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | string | `""` | no |
35-
| topic\_name | Name of pubsub topic connecting the scheduled projects cleanup function | string | `"pubsub_scheduled_project_cleaner"` | no |
23+
|------|-------------|------|---------|:--------:|
24+
| function\_timeout\_s | The amount of time in seconds allotted for the execution of the function. | `number` | `500` | no |
25+
| job\_schedule | Cleaner function run frequency, in cron syntax | `string` | `"*/5 * * * *"` | no |
26+
| max\_project\_age\_in\_hours | The maximum number of hours that a GCP project, selected by `target_tag_name` and `target_tag_value`, can exist | `number` | `6` | no |
27+
| organization\_id | The organization ID whose projects to clean up | `string` | n/a | yes |
28+
| project\_id | The project ID to host the scheduled function in | `string` | n/a | yes |
29+
| region | The region the project is in (App Engine specific) | `string` | n/a | yes |
30+
| target\_excluded\_labels | Map of project lablels that won't be deleted. | `map(string)` | `{}` | no |
31+
| target\_folder\_id | Folder ID to delete all projects under. | `string` | `""` | no |
32+
| target\_included\_labels | Map of project lablels that will be deleted. | `map(string)` | `{}` | no |
33+
| target\_tag\_name | The name of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | `string` | `""` | no |
34+
| target\_tag\_value | The value of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | `string` | `""` | no |
35+
| topic\_name | Name of pubsub topic connecting the scheduled projects cleanup function | `string` | `"pubsub_scheduled_project_cleaner"` | no |
3636

3737
## Outputs
3838

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
terraform {
18+
required_version = ">= 0.13"
19+
required_providers {
20+
21+
google = {
22+
source = "hashicorp/google"
23+
version = "~> 3.53"
24+
}
25+
}
26+
27+
provider_meta "google" {
28+
module_name = "blueprints/terraform/terraform-google-scheduled-function:project_cleanup/v1.0.0"
29+
}
30+
31+
}

0 commit comments

Comments
 (0)