diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index 699f91b..d5a44ec 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -14,10 +14,6 @@ * limitations under the License. */ -provider "google" { - version = "~> 3.53" -} - module "kms" { source = "../.." project_id = var.project_id diff --git a/examples/simple_example/versions.tf b/examples/simple_example/versions.tf new file mode 100644 index 0000000..37a1c11 --- /dev/null +++ b/examples/simple_example/versions.tf @@ -0,0 +1,25 @@ +/** + * 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_providers { + google = { + source = "hashicorp/google" + version = "~> 4.0" + } + } + required_version = ">= 0.13" +} diff --git a/main.tf b/main.tf index 9c0d422..192484a 100644 --- a/main.tf +++ b/main.tf @@ -15,7 +15,7 @@ */ locals { - keys_by_name = zipmap(var.keys, var.prevent_destroy ? slice(google_kms_crypto_key.key[*].self_link, 0, length(var.keys)) : slice(google_kms_crypto_key.key_ephemeral[*].self_link, 0, length(var.keys))) + keys_by_name = zipmap(var.keys, var.prevent_destroy ? slice(google_kms_crypto_key.key[*].id, 0, length(var.keys)) : slice(google_kms_crypto_key.key_ephemeral[*].id, 0, length(var.keys))) } resource "google_kms_key_ring" "key_ring" { @@ -27,7 +27,7 @@ resource "google_kms_key_ring" "key_ring" { resource "google_kms_crypto_key" "key" { count = var.prevent_destroy ? length(var.keys) : 0 name = var.keys[count.index] - key_ring = google_kms_key_ring.key_ring.self_link + key_ring = google_kms_key_ring.key_ring.id rotation_period = var.key_rotation_period lifecycle { @@ -45,7 +45,7 @@ resource "google_kms_crypto_key" "key" { resource "google_kms_crypto_key" "key_ephemeral" { count = var.prevent_destroy ? 0 : length(var.keys) name = var.keys[count.index] - key_ring = google_kms_key_ring.key_ring.self_link + key_ring = google_kms_key_ring.key_ring.id rotation_period = var.key_rotation_period lifecycle { diff --git a/outputs.tf b/outputs.tf index 48041ff..838fa4a 100644 --- a/outputs.tf +++ b/outputs.tf @@ -16,7 +16,7 @@ output "keyring" { description = "Self link of the keyring." - value = google_kms_key_ring.key_ring.self_link + value = google_kms_key_ring.key_ring.id # The grants are important to the key be ready to use. depends_on = [ diff --git a/test/setup/main.tf b/test/setup/main.tf index 9e238bc..aa7610e 100644 --- a/test/setup/main.tf +++ b/test/setup/main.tf @@ -14,11 +14,6 @@ * limitations under the License. */ - -provider "google" { - version = "~> 3.0" -} - module "project_ci_kms" { source = "terraform-google-modules/project-factory/google" version = "~> 10.0" diff --git a/test/setup/versions.tf b/test/setup/versions.tf index 832ec1d..edf9ab6 100644 --- a/test/setup/versions.tf +++ b/test/setup/versions.tf @@ -15,5 +15,11 @@ */ terraform { - required_version = ">= 0.12" + required_version = ">= 0.13" + required_providers { + google = { + source = "hashicorp/google" + version = "~> 3.0" + } + } } diff --git a/versions.tf b/versions.tf index afbebf2..3337b25 100644 --- a/versions.tf +++ b/versions.tf @@ -20,7 +20,7 @@ terraform { google = { source = "hashicorp/google" - version = "~> 3.53" + version = ">= 3.53, < 5.0" } }