Skip to content

Commit

Permalink
feat: update TPG version constraints to allow 4.0 (#50)
Browse files Browse the repository at this point in the history
* feat: update TPG version constraints to allow 4.0

* swap selflink to id

Co-authored-by: bharathkkb <[email protected]>
  • Loading branch information
cloud-foundation-bot and bharathkkb authored Dec 13, 2021
1 parent a4614d1 commit 14d80d7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
4 changes: 0 additions & 4 deletions examples/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
* limitations under the License.
*/

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

module "kms" {
source = "../.."
project_id = var.project_id
Expand Down
25 changes: 25 additions & 0 deletions examples/simple_example/versions.tf
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
5 changes: 0 additions & 5 deletions test/setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion test/setup/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
*/

terraform {
required_version = ">= 0.12"
required_version = ">= 0.13"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.0"
}
}
}
2 changes: 1 addition & 1 deletion 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"
version = ">= 3.53, < 5.0"
}
}

Expand Down

0 comments on commit 14d80d7

Please sign in to comment.