Skip to content

Commit

Permalink
feat: Add Terraform 0.13 constraint and module attribution (#792)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Minimum Terraform core version increased to 0.13.
  • Loading branch information
bharathkkb committed Jan 27, 2021
1 parent 4e4ce02 commit 32db990
Show file tree
Hide file tree
Showing 31 changed files with 308 additions and 52 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.12.2
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
4 changes: 2 additions & 2 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ resource "google_container_node_pool" "pools" {
}

dynamic "linux_node_config" {
for_each = merge(
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
) != {} ? [1] : []
)) != 0 ? [1] : []

content {
sysctls = merge(
Expand Down
37 changes: 30 additions & 7 deletions autogen/main/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,39 @@
* limitations under the License.
*/

{% set module_path_str = module_path|string %}
{% set module_registry_name = module_path_str.split('/')[-1] %}

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

required_providers {
{% if beta_cluster %}
google-beta = ">= 3.49.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
required_providers {
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.49.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
}
{% else %}
google = ">= 3.39.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
{% endif %}
required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.39.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
}
{% endif %}
}
9 changes: 8 additions & 1 deletion autogen/safer-cluster/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

{{ autogeneration_note }}

{% set module_path_str = module_path|string %}
{% set module_registry_name = module_path_str.split('/')[-1] %}

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

provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
}
}
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,6 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.2'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
options:
machineType: 'N1_HIGHCPU_8'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.12.2'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
options:
machineType: 'N1_HIGHCPU_8'
env:
Expand Down
3 changes: 2 additions & 1 deletion examples/safer_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ locals {
master_auth_subnetwork = "safer-cluster-master-subnet"
pods_range_name = "ip-range-pods-${random_string.suffix.result}"
svc_range_name = "ip-range-svc-${random_string.suffix.result}"
subnet_names = [for subnet_self_link in module.gcp-network.subnets_self_links : split("/", subnet_self_link)[length(split("/", subnet_self_link)) - 1]]
}

provider "google" {
Expand All @@ -53,7 +54,7 @@ module "gke" {
regional = true
region = var.region
network = module.gcp-network.network_name
subnetwork = module.gcp-network.subnets_names[index(module.gcp-network.subnets_names, local.subnet_name)]
subnetwork = local.subnet_names[index(module.gcp-network.subnets_names, local.subnet_name)]
ip_range_pods = local.pods_range_name
ip_range_services = local.svc_range_name
compute_engine_service_account = var.compute_engine_service_account
Expand Down
2 changes: 1 addition & 1 deletion examples/safer_cluster_iap_bastion/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 8.0"
version = "~> 10.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 1 addition & 1 deletion examples/safer_cluster_iap_bastion/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "google" {
version = "~> 3.42.0"
version = "~> 3.50.0"
}

provider "google-beta" {
Expand Down
24 changes: 24 additions & 0 deletions modules/asm/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* 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.
* 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_version = ">= 0.13.0"

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:asm/v13.0.0"
}
}
24 changes: 24 additions & 0 deletions modules/auth/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* 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.
* 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_version = ">= 0.13.0"

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:auth/v13.0.0"
}
}
4 changes: 2 additions & 2 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ resource "google_container_node_pool" "pools" {
}

dynamic "linux_node_config" {
for_each = merge(
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
) != {} ? [1] : []
)) != 0 ? [1] : []

content {
sysctls = merge(
Expand Down
16 changes: 13 additions & 3 deletions modules/beta-private-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
* limitations under the License.
*/


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

required_providers {
google-beta = ">= 3.49.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.49.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:beta-private-cluster-update-variant/v13.0.0"
}
}
4 changes: 2 additions & 2 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ resource "google_container_node_pool" "pools" {
}

dynamic "linux_node_config" {
for_each = merge(
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
) != {} ? [1] : []
)) != 0 ? [1] : []

content {
sysctls = merge(
Expand Down
16 changes: 13 additions & 3 deletions modules/beta-private-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
* limitations under the License.
*/


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

required_providers {
google-beta = ">= 3.49.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.49.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:beta-private-cluster/v13.0.0"
}
}
4 changes: 2 additions & 2 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ resource "google_container_node_pool" "pools" {
}

dynamic "linux_node_config" {
for_each = merge(
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
) != {} ? [1] : []
)) != 0 ? [1] : []

content {
sysctls = merge(
Expand Down
16 changes: 13 additions & 3 deletions modules/beta-public-cluster-update-variant/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
* limitations under the License.
*/


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

required_providers {
google-beta = ">= 3.49.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.49.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:beta-public-cluster-update-variant/v13.0.0"
}
}
4 changes: 2 additions & 2 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@ resource "google_container_node_pool" "pools" {
}

dynamic "linux_node_config" {
for_each = merge(
for_each = length(merge(
local.node_pools_linux_node_configs_sysctls["all"],
local.node_pools_linux_node_configs_sysctls[each.value["name"]]
) != {} ? [1] : []
)) != 0 ? [1] : []

content {
sysctls = merge(
Expand Down
16 changes: 13 additions & 3 deletions modules/beta-public-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
* limitations under the License.
*/


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

required_providers {
google-beta = ">= 3.49.0, <4.0.0"
kubernetes = "~> 1.10, != 1.11.0"
google-beta = {
source = "hashicorp/google-beta"
version = ">= 3.49.0, <4.0.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 1.10, != 1.11.0"
}
}
provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:beta-public-cluster/v13.0.0"
}
}
2 changes: 1 addition & 1 deletion modules/binary-authorization/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ locals {

module "project-services" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 9.2.0"
version = "~> 10.0"

project_id = var.project_id
activate_apis = local.required_enabled_apis
Expand Down
24 changes: 24 additions & 0 deletions modules/binary-authorization/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* 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.
* 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_version = ">= 0.13.0"

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:binary-authorization/v13.0.0"
}
}
24 changes: 24 additions & 0 deletions modules/hub/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* 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.
* 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_version = ">= 0.13.0"

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-kubernetes-engine:hub/v13.0.0"
}
}

0 comments on commit 32db990

Please sign in to comment.