Skip to content

Commit

Permalink
feat!: add Terraform 0.13 constraint and module attribution (#24)
Browse files Browse the repository at this point in the history
* feat!: add Terraform 0.13 constraint and module attribution

* Upgrades local-exec when detroy to terraform 13

Co-authored-by: cloud-foundation-bot <cloud-foundation-bot@google.com>
  • Loading branch information
amandakarina and cloud-foundation-bot authored Jun 24, 2021
1 parent 4194dea commit c90fe5c
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.11.6
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ The resources/services/activations/deletions that this module will create/trigge
- Create a Dataflow job

## Compatibility

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
is [0.3.0](https://registry.terraform.io/modules/terraform-google-modules/dataflow/google/0.3.0).
This module is meant for use with Terraform 0.13. If you haven't
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [v1.0.0](https://registry.terraform.io/modules/terraform-google-modules/-dataflow/google/v1.0.0).

## Usage

Expand Down Expand Up @@ -52,21 +53,21 @@ Then perform the following commands on the root folder:
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| ip\_configuration | The configuration for VM IPs. Options are 'WORKER_IP_PUBLIC' or 'WORKER_IP_PRIVATE'. | string | `"null"` | no |
| machine\_type | The machine type to use for the job. | string | `""` | no |
| max\_workers | The number of workers permitted to work on the job. More workers may improve processing speed at additional cost. | number | `"1"` | no |
| name | The name of the dataflow job | string | n/a | yes |
| network\_self\_link | The network self link to which VMs will be assigned. | string | `"default"` | no |
| on\_delete | One of drain or cancel. Specifies behavior of deletion during terraform destroy. The default is cancel. | string | `"cancel"` | no |
| parameters | Key/Value pairs to be passed to the Dataflow job (as used in the template). | map(string) | `<map>` | no |
| project\_id | The project in which the resource belongs. If it is not provided, the provider project is used. | string | n/a | yes |
| region | The region in which the created job should run. Also determines the location of the staging bucket if created. | string | `"us-central1"` | no |
| service\_account\_email | The Service Account email that will be used to identify the VMs in which the jobs are running | string | `""` | no |
| subnetwork\_self\_link | The subnetwork self link to which VMs will be assigned. | string | `""` | no |
| temp\_gcs\_location | A writeable location on GCS for the Dataflow job to dump its temporary data. | string | n/a | yes |
| template\_gcs\_path | The GCS path to the Dataflow job template. | string | n/a | yes |
| zone | The zone in which the created job should run. | string | `"us-central1-a"` | no |
|------|-------------|------|---------|:--------:|
| ip\_configuration | The configuration for VM IPs. Options are 'WORKER\_IP\_PUBLIC' or 'WORKER\_IP\_PRIVATE'. | `string` | `null` | no |
| machine\_type | The machine type to use for the job. | `string` | `""` | no |
| max\_workers | The number of workers permitted to work on the job. More workers may improve processing speed at additional cost. | `number` | `1` | no |
| name | The name of the dataflow job | `string` | n/a | yes |
| network\_self\_link | The network self link to which VMs will be assigned. | `string` | `"default"` | no |
| on\_delete | One of drain or cancel. Specifies behavior of deletion during terraform destroy. The default is cancel. | `string` | `"cancel"` | no |
| parameters | Key/Value pairs to be passed to the Dataflow job (as used in the template). | `map(string)` | `{}` | no |
| project\_id | The project in which the resource belongs. If it is not provided, the provider project is used. | `string` | n/a | yes |
| region | The region in which the created job should run. Also determines the location of the staging bucket if created. | `string` | `"us-central1"` | no |
| service\_account\_email | The Service Account email that will be used to identify the VMs in which the jobs are running | `string` | `""` | no |
| subnetwork\_self\_link | The subnetwork self link to which VMs will be assigned. | `string` | `""` | no |
| temp\_gcs\_location | A writeable location on GCS for the Dataflow job to dump its temporary data. | `string` | n/a | yes |
| template\_gcs\_path | The GCS path to the Dataflow job template. | `string` | n/a | yes |
| zone | The zone in which the created job should run. | `string` | `"us-central1-a"` | no |

## Outputs

Expand All @@ -93,7 +94,7 @@ The [project factory](https://github.com/terraform-google-modules/terraform-goog

### Software Dependencies
### Terraform
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x
- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v2.18.0

### Configure a Service Account to execute the module
Expand Down
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.11.6'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.11.6'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
12 changes: 7 additions & 5 deletions examples/dlp_api_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "google" {
version = "~> 2.18.0"
version = "~> 3.53"
region = var.region
}

Expand Down Expand Up @@ -129,12 +129,14 @@ module "dataflow-job" {
}

resource "null_resource" "destroy_deidentify_template" {
provisioner "local-exec" {
when = destroy
triggers = {
project_id = var.project_id
}

provisioner "local-exec" {
when = destroy
command = <<EOF
curl -s -X DELETE "https://dlp.googleapis.com/v2/projects/${var.project_id}/deidentifyTemplates/15" -H "Authorization:Bearer $(gcloud auth application-default print-access-token)"
curl -s -X DELETE "https://dlp.googleapis.com/v2/projects/${self.triggers.project_id}/deidentifyTemplates/15" -H "Authorization:Bearer $(gcloud auth application-default print-access-token)"
EOF

}
}
4 changes: 2 additions & 2 deletions examples/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "google" {
version = "~> 2.18.0"
version = "~> 3.53"
region = var.region
}

Expand All @@ -29,7 +29,7 @@ locals {

module "vpc" {
source = "terraform-google-modules/network/google"
version = "~> 1.0"
version = "~> 3.0"
project_id = var.project_id
network_name = "dataflow-network"

Expand Down
16 changes: 14 additions & 2 deletions modules/dataflow_bucket/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,5 +15,17 @@
*/

terraform {
required_version = ">= 0.12"
required_version = ">= 0.13"
required_providers {

google = {
source = "hashicorp/google"
version = "~> 3.53"
}
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-dataflow:dataflow_bucket/v1.0.0"
}

}
4 changes: 2 additions & 2 deletions test/setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

provider "google" {
version = "~> 2.18.0"
version = "~> 3.53"
}

module "project-ci-dataflow" {
source = "terraform-google-modules/project-factory/google"
version = "~> 3.0"
version = "~> 10.0"

name = "ci-test-df"
random_project_id = "true"
Expand Down
2 changes: 1 addition & 1 deletion test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/

terraform {
required_version = "~> 0.12.26"
required_version = ">= 0.12"
}
16 changes: 12 additions & 4 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,9 +15,17 @@
*/

terraform {
required_version = "~> 0.12.26"
required_version = ">= 0.13"
required_providers {
google = "~> 2.18"

google = {
source = "hashicorp/google"
version = "~> 3.53"
}
}
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-dataflow/v1.0.0"
}

}

0 comments on commit c90fe5c

Please sign in to comment.