Skip to content

feat!: Update for TF and CI, add instance test #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: "Close stale issues"
on:
schedule:
Expand Down
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 := 1.0
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.5
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ These sections describe requirements for using this module.

The following dependencies must be available:

- [Terraform][terraform] v0.12
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v2.0
- [Terraform][terraform] v0.13+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v4.12

### Service Account

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: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.5'
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: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.5'
16 changes: 16 additions & 0 deletions examples/hub_artifact/versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

terraform {
required_providers {
cdap = {
Expand Down
5 changes: 4 additions & 1 deletion examples/instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ This example illustrates how to use the `data-fusion` module.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| data\_fusion\_service\_account | Google Managed Data Fusion Service Account Email | `any` | n/a | yes |
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |

## Outputs

No output.
| Name | Description |
|------|-------------|
| instance\_id | The created Google Data Fusion instance ID |

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

Expand Down
8 changes: 5 additions & 3 deletions examples/instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
module "data_fusion" {
source = "../../"

name = "example-instance"
project = var.project_id
region = "us-central1"
name = "example-instance"
project = var.project_id
region = "us-central1"
network = "default"
data_fusion_service_account = var.data_fusion_service_account
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020 Google LLC
* Copyright 2022 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 @@ -14,6 +14,7 @@
* limitations under the License.
*/

terraform {
required_version = ">= 0.12"
output "instance_id" {
description = "The created Google Data Fusion instance ID"
value = module.data_fusion.instance.id
}
1 change: 1 addition & 0 deletions examples/instance/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This example illustrates how to use the `data-fusion` module.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| data\_fusion\_service\_account | Google Managed Data Fusion Service Account Email | `any` | n/a | yes |
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |

## Outputs
Expand Down
10 changes: 6 additions & 4 deletions examples/instance/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/

module "data_fusion" {
source = "../../"
source = "../../../"

name = "example-instance"
project = var.project_id
region = "us-central1"
name = "example-instance"
project = var.project_id
region = "us-central1"
network = "default"
data_fusion_service_account = var.data_fusion_service_account
}
4 changes: 4 additions & 0 deletions examples/instance/simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ variable "project_id" {
description = "The ID of the project in which to provision resources."
type = string
}

variable "data_fusion_service_account" {
description = "Google Managed Data Fusion Service Account Email"
}
4 changes: 4 additions & 0 deletions examples/instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ variable "project_id" {
description = "The ID of the project in which to provision resources."
type = string
}

variable "data_fusion_service_account" {
description = "Google Managed Data Fusion Service Account Email"
}
19 changes: 0 additions & 19 deletions examples/instance/versions.tf

This file was deleted.

13 changes: 5 additions & 8 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
---
driver:
name: terraform
command_timeout: 2700
verify_version: false

provisioner:
name: terraform
Expand All @@ -26,18 +28,13 @@ platforms:
- name: default

suites:
- name: simple_example
- name: instance
driver:
root_module_directory: test/fixtures/simple_example/
root_module_directory: test/fixtures/instance/
verifier:
color: false
systems:
- name: simple_example local
- name: instance local
backend: local
controls:
- gcloud
- gsutil
- name: simple_example gcp
backend: gcp
controls:
- gcp
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ module "data_fusion_network" {
module "instance" {
source = "./modules/instance"

name = var.name
project = var.project
description = var.description
region = var.region
type = var.type
labels = var.labels
datafusion_version = var.datafusion_version
options = var.options
name = var.name
project = var.project
description = var.description
region = var.region
type = var.type
labels = var.labels
datafusion_version = var.datafusion_version
options = var.options
network_config = {
network = module.data_fusion_network.data_fusion_vpc.network_name
ip_allocation = module.data_fusion_network.data_fusion_ip_allocation
Expand Down
4 changes: 4 additions & 0 deletions modules/dataproc_profile/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ terraform {
source = "hashicorp/google"
version = ">= 3.53, < 5.0"
}
cdap = {
source = "GoogleCloudPlatform/cdap"
version = "~> 0.9.0"
}
}

provider_meta "google" {
Expand Down
4 changes: 4 additions & 0 deletions modules/hub_artifact/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ terraform {
source = "hashicorp/google"
version = ">= 3.53, < 5.0"
}
cdap = {
source = "GoogleCloudPlatform/cdap"
version = "~> 0.9.0"
}
}

provider_meta "google" {
Expand Down
6 changes: 1 addition & 5 deletions modules/instance/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ output "instance" {
description = "The created CDF instance"
}

locals {
tenant_project_re = "cloud-datafusion-management-sa@([\\w-]+).iam.gserviceaccount.com"
}

output "tenant_project" {
value = regex(local.tenant_project_re, google_data_fusion_instance.instance.service_account)[0]
description = "The Google managed tenant project ID in which the instance will run its jobs"
value = google_data_fusion_instance.instance.tenant_project_id
}

output "service_account" {
Expand Down
10 changes: 9 additions & 1 deletion modules/instance/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
*/

terraform {
required_version = "~> 0.12.6"
required_version = ">= 0.13"

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-data-fusion:instance/v1.1.0"
}

provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-data-fusion:instance/v1.1.0"
}
}
5 changes: 5 additions & 0 deletions modules/namespace/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ terraform {
source = "hashicorp/google"
version = ">= 3.53, < 5.0"
}
cdap = {
source = "GoogleCloudPlatform/cdap"
version = "~> 0.9.0"
}

}

provider_meta "google" {
Expand Down
2 changes: 1 addition & 1 deletion modules/private_network/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Data Fusion Private Network Setup

This module can be used to deploy the networking pre-reqs for a
This module can be used to deploy the networking pre-reqs for a
[Private IP Data Fusion Instance](https://cloud.google.com/data-fusion/docs/how-to/create-private-ip).
Namely:
- VPC Network
Expand Down
15 changes: 7 additions & 8 deletions modules/private_network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "vpc" {
source = "terraform-google-modules/network/google"
version = "~> 2.2"
version = "~> 5.1"
project_id = var.project_id
network_name = var.network_name
routing_mode = "GLOBAL"
Expand All @@ -31,13 +31,12 @@ module "vpc" {
]
}

module "peering" {
source = "terraform-google-modules/network/google//modules/network-peering"
prefix = "data-fusion-peering"
local_network = module.vpc.network_self_link
peer_network = "projects/${var.tenant_project}/global/networks/${var.region}-${var.instance}"
export_local_custom_routes = true
export_peer_custom_routes = true
resource "google_compute_network_peering" "data-fusion-peering" {
name = "data-fusion-peering"
network = module.vpc.network_self_link
peer_network = "projects/${var.tenant_project}/global/networks/${var.region}-${var.instance}"
export_custom_routes = true
import_custom_routes = true
}

resource "google_compute_global_address" "data_fusion_private_ip_alloc" {
Expand Down
1 change: 1 addition & 0 deletions modules/private_network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ variable "tenant_project" {
description = "Private Data Fusion instance ID"
type = string
}

variable "data_fusion_service_account" {
description = "The Google managed Data Fusion Service account"
type = string
Expand Down
2 changes: 1 addition & 1 deletion modules/private_network/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {

google = {
source = "hashicorp/google"
version = ">= 3.53, < 5.0"
version = ">= 4.12, < 5.0"
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/wait_healthy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ These sections describe requirements for using this module.

The following dependencies must be available:

- [Terraform][terraform] v0.12
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v2.0
- [Terraform][terraform] v0.13+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v3.53+

### Service Account

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
* limitations under the License.
*/

terraform {
required_version = ">= 0.13"
required_providers {
random = {
source = "hashicorp/random"
version = "~> 2.0"
}
}
module "example" {
source = "../../../examples/instance"

project_id = var.project_id
data_fusion_service_account = var.sa_key
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

output "bucket_name" {
description = "The name of the bucket."
value = module.example.bucket_name
}

output "project_id" {
description = "The ID of the project in which resources are provisioned."
value = var.project_id
}

output "instance_id" {
description = "The created Google Data Fusion instance id"
value = module.example.instance_id
}
Loading