Skip to content

Commit f82327d

Browse files
authored
Merge pull request #25 from terraform-google-modules/aaron-lane-0.12
Release 0.12
2 parents d3c322d + 4bbdce2 commit f82327d

File tree

37 files changed

+1051
-268
lines changed

37 files changed

+1051
-268
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
66
project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [Unreleased] - major
8+
## [Unreleased]
9+
10+
## [1.0.0] - 2019-YY-ZZ
911

1012
### Changed
1113

14+
- Supported version of Terraform is 0.12. [#23]
1215
- Support aggregated log exports by integrating log-export module. [#18]
1316

1417
## [0.1.0] - 2019-04-03
@@ -20,4 +23,5 @@ project adheres to [Semantic Versioning](http://semver.org/).
2023
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-event-function/compare/v0.1.0...HEAD
2124
[0.1.0]: https://github.com/terraform-google-modules/terraform-google-event-function/releases/tag/v0.1.0
2225

26+
[#23]: https://github.com/terraform-google-modules/terraform-google-event-function/pull/23
2327
[#18]: https://github.com/terraform-google-modules/terraform-google-event-function/pull/18

Makefile

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SHELL := /usr/bin/env bash
2121
# Docker build config variables
2222
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
2323
DOCKER_ORG := gcr.io/cloud-foundation-cicd
24-
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 1.0.0
24+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.3.0
2525
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
2626

2727
all: check generate_docs
@@ -76,48 +76,59 @@ version:
7676
.PHONY: docker_run
7777
docker_run:
7878
docker run --rm -it \
79-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
79+
-e PROJECT_ID \
80+
-e SERVICE_ACCOUNT_JSON \
8081
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
8182
-v $(CURDIR):/cft/workdir \
8283
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
83-
/bin/bash
84+
/bin/bash -c "source test/integration.sh && setup_environment && exec /bin/bash"
8485

8586
.PHONY: docker_create
8687
docker_create:
8788
docker run --rm -it \
88-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
89+
-e PROJECT_ID \
90+
-e SERVICE_ACCOUNT_JSON \
8991
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
9092
-v $(CURDIR):/cft/workdir \
9193
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
92-
/bin/bash -c "kitchen create"
94+
/bin/bash -c "source test/integration.sh && setup_environment && kitchen create"
9395

9496
.PHONY: docker_converge
9597
docker_converge:
9698
docker run --rm -it \
97-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
99+
-e PROJECT_ID \
100+
-e SERVICE_ACCOUNT_JSON \
98101
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
99102
-v $(CURDIR):/cft/workdir \
100103
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
101-
/bin/bash -c "kitchen converge && kitchen converge"
104+
/bin/bash -c "source test/integration.sh && setup_environment && kitchen converge"
102105

103106
.PHONY: docker_verify
104107
docker_verify:
105108
docker run --rm -it \
106-
-e CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=${CREDENTIALS_PATH} \
109+
-e PROJECT_ID \
110+
-e SERVICE_ACCOUNT_JSON \
107111
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
108112
-v $(CURDIR):/cft/workdir \
109113
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
110-
/bin/bash -c "kitchen verify"
114+
/bin/bash -c "source test/integration.sh && setup_environment && kitchen verify"
111115

112116
.PHONY: docker_destroy
113117
docker_destroy:
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} \
117122
-v $(CURDIR):/cft/workdir \
118123
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
119-
/bin/bash -c "kitchen destroy"
124+
/bin/bash -c "source test/integration.sh && setup_environment && kitchen destroy"
120125

121126
.PHONY: test_integration_docker
122-
test_integration_docker: docker_create docker_converge docker_verify docker_destroy
123-
@echo "Running test-kitchen tests in docker"
127+
test_integration_docker:
128+
docker run --rm -it \
129+
-e PROJECT_ID \
130+
-e SERVICE_ACCOUNT_JSON \
131+
-e GOOGLE_APPLICATION_CREDENTIALS=${CREDENTIALS_PATH} \
132+
-v $(CURDIR):/cft/workdir \
133+
${DOCKER_REPO_BASE_KITCHEN_TERRAFORM} \
134+
make test_integration

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Alternatively, the
1313
configures a function sourced from a Cloud Source Repositories
1414
repository.
1515

16+
## Compatibility
17+
18+
This module is meant for use with Terraform 0.12. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-12.html) and need a Terraform 0.11.x-compatible version of this module, the last released version intended for Terraform 0.11.x
19+
is [0.1.0](https://registry.terraform.io/modules/terraform-google-modules/event-function/google/0.1.0).
20+
21+
1622
## Usage
1723

1824
The
@@ -57,11 +63,11 @@ order to invoke this module.
5763
The following software dependencies must be installed on the system
5864
from which this module will be invoked:
5965

60-
- [Terraform][terraform-site] v0.11.Z
66+
- [Terraform][terraform-site] v0.12.Z
6167
- [Terraform Provider for Archive][terraform-provider-archive-site]
6268
v1.2.Z
6369
- [Terraform Provider for Google Cloud Platform][terraform-provider-gcp-site]
64-
v2.1.Z
70+
v2.5.Z
6571

6672
### IAM Roles
6773

examples/automatic-labelling-from-localhost/function_source/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ authenticate = callback => {
4949
* @param {!Function} callback A callback function to signal completion.
5050
*/
5151
fetchLabels = ({ authClient, instance, project, zone }, callback) => {
52-
console.log("Fetching labels");
52+
console.log("Fetching labels for " + instance);
5353
compute.instances.get(
5454
{ auth: authClient, instance, project, zone }, (error, response) => {
5555
if (error) {
@@ -84,7 +84,7 @@ fetchLabels = ({ authClient, instance, project, zone }, callback) => {
8484
storeLabels =
8585
({ authClient, instance, labelFingerprint, labels, project, zone },
8686
callback) => {
87-
console.log("Storing labels");
87+
console.log("Storing labels for " + instance);
8888
compute.instances.setLabels(
8989
{
9090
auth: authClient,

examples/automatic-labelling-from-localhost/main.tf

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

1717
terraform {
18-
required_version = "~> 0.11.0"
18+
required_version = "~> 0.12.0"
1919
}
2020

2121
provider "archive" {
@@ -31,7 +31,7 @@ provider "random" {
3131
}
3232

3333
provider "null" {
34-
version = "~> 1.0"
34+
version = "~> 2.1"
3535
}
3636

3737
resource "random_pet" "main" {
@@ -42,8 +42,8 @@ module "event_project_log_entry" {
4242
source = "../../modules/event-project-log-entry"
4343

4444
filter = "protoPayload.@type=\"type.googleapis.com/google.cloud.audit.AuditLog\" protoPayload.methodName:insert operation.first=true"
45-
name = "${random_pet.main.id}"
46-
project_id = "${var.project_id}"
45+
name = random_pet.main.id
46+
project_id = var.project_id
4747
}
4848

4949
module "localhost_function" {
@@ -56,10 +56,10 @@ module "localhost_function" {
5656
LABEL_KEY = "principal-email"
5757
}
5858

59-
event_trigger = "${module.event_project_log_entry.function_event_trigger}"
60-
name = "${random_pet.main.id}"
61-
project_id = "${var.project_id}"
62-
region = "${var.region}"
59+
event_trigger = module.event_project_log_entry.function_event_trigger
60+
name = random_pet.main.id
61+
project_id = var.project_id
62+
region = var.region
6363
source_directory = "${path.module}/function_source"
6464
runtime = "nodejs8"
6565
}
@@ -69,25 +69,31 @@ resource "null_resource" "wait_for_function" {
6969
command = "sleep 60"
7070
}
7171

72-
depends_on = ["module.localhost_function"]
72+
depends_on = [module.localhost_function]
7373
}
7474

7575
resource "google_compute_instance" "main" {
76-
boot_disk = {
77-
initialize_params = {
76+
boot_disk {
77+
initialize_params {
7878
image = "debian-cloud/debian-9"
7979
}
8080
}
8181

8282
machine_type = "f1-micro"
8383
name = "unlabelled-${random_pet.main.id}"
84-
zone = "${var.zone}"
84+
zone = var.zone
85+
86+
lifecycle {
87+
ignore_changes = [
88+
labels,
89+
]
90+
}
8591

86-
network_interface = {
92+
network_interface {
8793
network = "default"
8894
}
8995

90-
project = "${var.project_id}"
96+
project = var.project_id
9197

92-
depends_on = ["null_resource.wait_for_function"]
98+
depends_on = [null_resource.wait_for_function]
9399
}

examples/automatic-labelling-from-localhost/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
*/
1616

1717
output "compute_instance_name" {
18-
value = "${google_compute_instance.main.name}"
18+
value = google_compute_instance.main.name
1919
description = "The name of the unlabelled Compute instance."
2020
}

examples/automatic-labelling-from-localhost/variables.tf

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

1717
variable "project_id" {
18-
type = "string"
18+
type = string
1919
description = "The ID of the project to which resources will be applied."
2020
}
2121

2222
variable "region" {
23-
type = "string"
23+
type = string
2424
description = "The region in which resources will be applied."
2525
}
2626

2727
variable "zone" {
28-
type = "string"
28+
type = string
2929
description = "The zone in which resources will be applied."
3030
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/function_source_copy

examples/automatic-labelling-from-repository/function_source/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ authenticate = callback => {
4949
* @param {!Function} callback A callback function to signal completion.
5050
*/
5151
fetchLabels = ({ authClient, instance, project, zone }, callback) => {
52-
console.log("Fetching labels");
52+
console.log("Fetching labels for " + instance);
5353
compute.instances.get(
5454
{ auth: authClient, instance, project, zone }, (error, response) => {
5555
if (error) {
@@ -84,7 +84,7 @@ fetchLabels = ({ authClient, instance, project, zone }, callback) => {
8484
storeLabels =
8585
({ authClient, instance, labelFingerprint, labels, project, zone },
8686
callback) => {
87-
console.log("Storing labels");
87+
console.log("Storing labels for " + instance);
8888
compute.instances.setLabels(
8989
{
9090
auth: authClient,

examples/automatic-labelling-from-repository/main.tf

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

1717
terraform {
18-
required_version = "~> 0.11.0"
18+
required_version = "~> 0.12.0"
1919
}
2020

2121
provider "archive" {
@@ -31,28 +31,28 @@ provider "random" {
3131
}
3232

3333
provider "null" {
34-
version = "~> 1.0"
34+
version = "~> 2.1"
3535
}
3636

3737
resource "random_pet" "main" {
3838
separator = "-"
3939
}
4040

4141
resource "google_sourcerepo_repository" "main" {
42-
name = "${random_pet.main.id}"
43-
project = "${var.project_id}"
42+
name = random_pet.main.id
43+
project = var.project_id
4444
}
4545

4646
resource "null_resource" "configure_repository" {
47-
triggers {
48-
repository_url = "${google_sourcerepo_repository.main.url}"
47+
triggers = {
48+
repository_url = google_sourcerepo_repository.main.url
4949
}
5050

5151
provisioner "local-exec" {
5252
command = "${path.module}/scripts/configure_repository.sh"
5353

54-
environment {
55-
REMOTE_URL = "${google_sourcerepo_repository.main.url}"
54+
environment = {
55+
REMOTE_URL = google_sourcerepo_repository.main.url
5656
REPOSITORY_DIRECTORY = "${path.module}/function_source"
5757
REPOSITORY_COPY_DIRECTORY = "${path.module}/function_source_copy"
5858
}
@@ -64,15 +64,15 @@ data "null_data_source" "main" {
6464
source_repository_url = "https://source.developers.google.com/projects/${var.project_id}/repos/${random_pet.main.id}/moveable-aliases/master/paths/"
6565
}
6666

67-
depends_on = ["null_resource.configure_repository"]
67+
depends_on = [null_resource.configure_repository]
6868
}
6969

7070
module "event_project_log_entry" {
7171
source = "../../modules/event-project-log-entry"
7272

7373
filter = "protoPayload.@type=\"type.googleapis.com/google.cloud.audit.AuditLog\" protoPayload.methodName:insert operation.first=true"
74-
name = "${random_pet.main.id}"
75-
project_id = "${var.project_id}"
74+
name = random_pet.main.id
75+
project_id = var.project_id
7676
}
7777

7878
module "repository_function" {
@@ -86,37 +86,43 @@ module "repository_function" {
8686
LABEL_KEY = "principal-email"
8787
}
8888

89-
event_trigger = "${module.event_project_log_entry.function_event_trigger}"
90-
name = "${random_pet.main.id}"
91-
project_id = "${var.project_id}"
92-
region = "${var.region}"
93-
source_repository_url = "${data.null_data_source.main.outputs["source_repository_url"]}"
89+
event_trigger = module.event_project_log_entry.function_event_trigger
90+
name = random_pet.main.id
91+
project_id = var.project_id
92+
region = var.region
93+
source_repository_url = data.null_data_source.main.outputs["source_repository_url"]
9494
}
9595

9696
resource "null_resource" "wait_for_function" {
9797
provisioner "local-exec" {
9898
command = "sleep 60"
9999
}
100100

101-
depends_on = ["module.repository_function"]
101+
depends_on = [module.repository_function]
102102
}
103103

104104
resource "google_compute_instance" "main" {
105-
boot_disk = {
106-
initialize_params = {
105+
boot_disk {
106+
initialize_params {
107107
image = "debian-cloud/debian-9"
108108
}
109109
}
110110

111111
machine_type = "f1-micro"
112112
name = "unlabelled-${random_pet.main.id}"
113-
zone = "${var.zone}"
113+
zone = var.zone
114+
115+
lifecycle {
116+
ignore_changes = [
117+
labels,
118+
]
119+
}
114120

115-
network_interface = {
121+
network_interface {
116122
network = "default"
117123
}
118124

119-
project = "${var.project_id}"
125+
project = var.project_id
120126

121-
depends_on = ["null_resource.wait_for_function"]
127+
depends_on = [null_resource.wait_for_function]
122128
}

0 commit comments

Comments
 (0)