Skip to content

Commit 074443b

Browse files
authored
Merge pull request #11 from bohdanyurov-gl/fix/9
Add support for Terraform 0.12
2 parents aa3ae39 + 06c2e67 commit 074443b

File tree

24 files changed

+929
-180
lines changed

24 files changed

+929
-180
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ terraform.tfstate
44
credentials.json
55
*.iml
66
.idea
7+
*.pyc
8+
.kitchen
79

810
examples/**/*.zip
911
examples/**/terraform.tfvars

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog][keepachangelog-site],
66
and this project adheres to [Semantic Versioning][semver-site].
77

8-
98
## [Unreleased]
109

10+
## [1.0.0] - 2019-YY-ZZ
11+
12+
### Changed
13+
14+
- Supported version of Terraform is 0.12. [#11]
15+
1116
## [0.4.1] - 2019-07-03
1217

1318
### Fixed
@@ -45,6 +50,7 @@ and this project adheres to [Semantic Versioning][semver-site].
4550
[0.2.0]: https://github.com/terraform-google-modules/terraform-google-scheduled-function/compare/v0.1.0...v0.2.0
4651
[0.1.0]: https://github.com/terraform-google-modules/terraform-google-scheduled-function/releases/tag/v0.1.0
4752

53+
[#11]: https://github.com/terraform-google-modules/terraform-google-scheduled-function/pull/11
4854
[#8]: https://github.com/terraform-google-modules/terraform-google-scheduled-function/pull/8
4955
[#5]: https://github.com/terraform-google-modules/terraform-google-scheduled-function/pull/5
5056

Makefile

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ SHELL := /usr/bin/env bash
1818
# Docker build config variables
1919
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
2020
DOCKER_ORG := gcr.io/cloud-foundation-cicd
21-
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.11_235.0.0_1.19.1_0.1.10
21+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.3.0
2222
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
2323

2424
# All is the first target in the file so it will get picked up when you just run 'make' on its own
25-
all: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace generate_docs
25+
all: check generate_docs
26+
27+
.PHONY: check
28+
check: check_shell check_python check_golang check_terraform check_docker check_base_files test_check_headers check_headers check_trailing_whitespace
29+
2630

2731
# The .PHONY directive tells make that this isn't a real target and so
2832
# the presence of a file named 'check_shell' won't cause this target to stop
@@ -82,53 +86,59 @@ version:
8286
.PHONY: docker_run
8387
docker_run:
8488
docker run --rm -it \
85-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
89+
-e PROJECT_ID \
90+
-e SERVICE_ACCOUNT_JSON \
8691
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
87-
-e TF_VAR_project_id \
8892
-v $(CURDIR):/cft/workdir \
8993
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
90-
/bin/bash
94+
/bin/bash -c "source test/ci_integration.sh && setup_environment && exec /bin/bash"
9195

9296
.PHONY: docker_create
9397
docker_create:
9498
docker run --rm -it \
95-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
99+
-e PROJECT_ID \
100+
-e SERVICE_ACCOUNT_JSON \
96101
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
97-
-e TF_VAR_project_id \
98102
-v $(CURDIR):/cft/workdir \
99103
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
100-
/bin/bash -c "kitchen create"
104+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen create"
101105

102106
.PHONY: docker_converge
103107
docker_converge:
104108
docker run --rm -it \
105-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
109+
-e PROJECT_ID \
110+
-e SERVICE_ACCOUNT_JSON \
106111
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
107-
-e TF_VAR_project_id \
108112
-v $(CURDIR):/cft/workdir \
109113
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
110-
/bin/bash -c "kitchen converge && kitchen converge"
114+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen converge"
111115

112116
.PHONY: docker_verify
113117
docker_verify:
114118
docker run --rm -it \
115-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
119+
-e PROJECT_ID \
120+
-e SERVICE_ACCOUNT_JSON \
116121
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
117-
-e TF_VAR_project_id \
118122
-v $(CURDIR):/cft/workdir \
119123
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
120-
/bin/bash -c "kitchen verify"
124+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen verify"
121125

122126
.PHONY: docker_destroy
123127
docker_destroy:
124128
docker run --rm -it \
125-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
129+
-e PROJECT_ID \
130+
-e SERVICE_ACCOUNT_JSON \
126131
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
127-
-e TF_VAR_project_id \
128132
-v $(CURDIR):/cft/workdir \
129133
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
130-
/bin/bash -c "kitchen destroy"
134+
/bin/bash -c "source test/ci_integration.sh && setup_environment && kitchen destroy"
131135

132136
.PHONY: test_integration_docker
133-
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
134-
@echo "Running test-kitchen tests in docker"
137+
test_integration_docker:
138+
docker run --rm -it \
139+
-e PROJECT_ID \
140+
-e SERVICE_ACCOUNT_JSON \
141+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
142+
-v $(CURDIR):/cft/workdir \
143+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
144+
make test_integration

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Terraform Google Scheduled Functions Module
2+
23
This modules makes it easy to set up a scheduled job to trigger events/run functions.
34

5+
## 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).
11+
412
## Usage
513
You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:
614

@@ -62,15 +70,16 @@ Then perform the following commands on the root folder:
6270

6371
## Requirements
6472
### Terraform plugins
65-
- [Terraform](https://www.terraform.io/downloads.html) 0.11.x
73+
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x
6674
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v2.1
6775

6876
### App Engine
69-
Note that this module requires App Engine being configured in the specified project/region.
77+
Note that this module requires App Engine being configured in the specified project/region.
7078
This is because Google Cloud Scheduler is dependent on the project being configured with App Engine.
71-
Refer to the [Google Cloud Scheduler documentation](https://cloud.google.com/scheduler/docs/) for more information on the App Engine dependency.
79+
Refer to the [Google Cloud Scheduler documentation](https://cloud.google.com/scheduler/docs/) for more
80+
information on the App Engine dependency.
7281

73-
The recommended way to create projects with App Engine enabled is via the [Project Factory module](https://github.com/terraform-google-modules/terraform-google-project-factory).
82+
The recommended way to create projects with App Engine enabled is via the [Project Factory module](https://github.com/terraform-google-modules/terraform-google-project-factory).
7483
There is an example of how to create the project [within that module](https://github.com/terraform-google-modules/terraform-google-project-factory/tree/master/examples/app_engine)
7584

7685
### Configure a Service Account
@@ -93,7 +102,7 @@ In order to operate with the Service Account you must activate the following API
93102
## Install
94103

95104
### Terraform
96-
Be sure you have the correct Terraform version (0.11.x), you can choose the binary here:
105+
Be sure you have the correct Terraform version (0.12.x), you can choose the binary here:
97106
- https://releases.hashicorp.com/terraform/
98107

99108
## Testing and documentation generation

examples/pubsub_scheduled/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This example module schedules a job to publish a message to a Pub/Sub topic every 5 minutes, which will trigger a CloudFunctions function.
44

5-
Running this module requires an App Engine app in the specified project/region, which is not handled by this example.
5+
Running this module requires an App Engine app in the specified project/region, which is not handled by this example.
66
More information is in the [root readme](../../README.md#app-engine).
77

88
[^]: (autogen_docs_start)
-869 Bytes
Binary file not shown.

examples/pubsub_scheduled/main.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17+
terraform {
18+
required_version = ">= 0.12"
19+
}
20+
1721
provider "google-beta" {
18-
version = "~> 2.1"
19-
project = "${var.project_id}"
20-
region = "${var.region}"
22+
version = "~> 2.5"
23+
project = var.project_id
24+
region = var.region
2125
}
2226

2327
module "pubsub_scheduled_example" {
2428
providers = {
25-
google = "google-beta"
29+
google = google-beta
2630
}
2731

2832
source = "../../"
29-
project_id = "${var.project_id}"
33+
project_id = var.project_id
3034
job_name = "pubsub-example"
3135
job_schedule = "*/5 * * * *"
3236
function_entry_point = "doSomething"
3337
function_source_directory = "${path.module}/function_source"
3438
function_name = "testfunction-foo"
35-
region = "${var.region}"
39+
region = var.region
3640
topic_name = "pubsub_example_topic"
3741
}

examples/pubsub_scheduled/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616

1717
output "name" {
18-
value = "${module.pubsub_scheduled_example.name}"
18+
value = module.pubsub_scheduled_example.name
1919
description = "The name of the job created"
2020
}
2121

2222
output "project_id" {
23-
value = "${var.project_id}"
23+
value = var.project_id
2424
description = "The project ID"
2525
}

examples/pubsub_scheduled/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
*/
1616

1717
variable "project_id" {
18+
type = string
1819
description = "The project ID to host the network in"
1920
}
2021

2122
variable "region" {
23+
type = string
2224
description = "The region the project is in (App Engine specific)"
2325
default = "us-central1"
2426
}

helpers/combine_docfiles.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)