From d1a698245c3560b6c458c5d282d91198fc2a00ec Mon Sep 17 00:00:00 2001 From: Will Ripley Date: Tue, 16 Jul 2019 13:28:33 -0700 Subject: [PATCH 1/2] Updated tf to 0.12 (patch applied from https://github.com/GoogleCloudPlatform/gke-logging-sinks-demo/pull/30). --- Jenkinsfile | 2 +- terraform/main.tf | 16 +++++++++------- terraform/provider.tf | 6 +++--- terraform/variables.tf | 6 +++--- terraform/versions.tf | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 terraform/versions.tf diff --git a/Jenkinsfile b/Jenkinsfile index e353334..26430c7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ metadata: spec: containers: - name: ${containerName} - image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${env.CONTAINER_VERSION} + image: gcr.io/pso-helmsman-cicd/jenkins-k8s-node:${env.JENKINS_CONTAINER_VERSION} command: ['cat'] tty: true volumeMounts: diff --git a/terraform/main.tf b/terraform/main.tf index b9f4a96..2ef0bbe 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -26,8 +26,8 @@ limitations under the License. // Provides access to available Google Container Engine versions in a zone for a given project. // https://www.terraform.io/docs/providers/google/d/google_container_engine_versions.html data "google_container_engine_versions" "on-prem" { - zone = "${var.zone}" - project = "${var.project}" + zone = var.zone + project = var.project } /////////////////////////////////////////////////////////////////////////////////////// @@ -55,7 +55,7 @@ resource "google_bigquery_dataset" "gke-bigquery-dataset" { location = "US" default_table_expiration_ms = 3600000 - labels { + labels = { env = "default" } } @@ -68,9 +68,9 @@ resource "google_bigquery_dataset" "gke-bigquery-dataset" { // https://www.terraform.io/docs/providers/google/d/google_container_cluster.html resource "google_container_cluster" "primary" { name = "stackdriver-logging" - zone = "${var.zone}" + zone = var.zone initial_node_count = 2 - min_master_version = "${data.google_container_engine_versions.on-prem.latest_master_version}" + min_master_version = data.google_container_engine_versions.on-prem.latest_master_version node_config { oauth_scopes = [ @@ -81,6 +81,7 @@ resource "google_container_cluster" "primary" { ] } + // These local-execs are used to provision the sample service // These local-execs are used to provision the sample service provisioner "local-exec" { command = "gcloud container clusters get-credentials ${google_container_cluster.primary.name} --zone ${google_container_cluster.primary.zone} --project ${var.project}" @@ -125,7 +126,7 @@ resource "google_project_iam_binding" "log-writer-storage" { role = "roles/storage.objectCreator" members = [ - "${google_logging_project_sink.storage-sink.writer_identity}", + google_logging_project_sink.storage-sink.writer_identity, ] } @@ -134,6 +135,7 @@ resource "google_project_iam_binding" "log-writer-bigquery" { role = "roles/bigquery.dataEditor" members = [ - "${google_logging_project_sink.bigquery-sink.writer_identity}", + google_logging_project_sink.bigquery-sink.writer_identity, ] } + diff --git a/terraform/provider.tf b/terraform/provider.tf index 459bff2..1dd82a1 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ - // Configles the Google Cloud Provider with default settings provider "google" { - project = "${var.project}" - version = "~> 1.13" + project = var.project + version = "~> 2.10.0" } + diff --git a/terraform/variables.tf b/terraform/variables.tf index c3dc91a..bc72994 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ - /* Required Variables These must be provided at runtime. @@ -22,10 +21,11 @@ These must be provided at runtime. variable "zone" { description = "The zone in which to create the Kubernetes cluster. Must match the region" - type = "string" + type = string } variable "project" { description = "The name of the project in which to create the Kubernetes cluster." - type = "string" + type = string } + diff --git a/terraform/versions.tf b/terraform/versions.tf new file mode 100644 index 0000000..c51f32c --- /dev/null +++ b/terraform/versions.tf @@ -0,0 +1,19 @@ +/* +Copyright 2018 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 + + https://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_version = ">= 0.12" +} From 1c810cdb8b497c781587fa47f35e96396a5d46a3 Mon Sep 17 00:00:00 2001 From: Will Ripley Date: Wed, 17 Jul 2019 05:26:43 -0700 Subject: [PATCH 2/2] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64f616b..f9449d5 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ gcloud init ### Tools -1. [Terraform >= 0.11.7](https://www.terraform.io/downloads.html) +1. [Terraform >= 0.12](https://www.terraform.io/downloads.html) 2. [Google Cloud SDK version >= 204.0.0](https://cloud.google.com/sdk/docs/downloads-versioned-archives) 3. [kubectl matching the latest GKE version](https://kubernetes.io/docs/tasks/tools/install-kubectl/) 4. bash or bash compatible shell