From dfc3d20f1308c7f603f5208c8499062a23a13987 Mon Sep 17 00:00:00 2001 From: Ivan Kornienko Date: Thu, 8 Aug 2019 18:37:06 +0300 Subject: [PATCH] Fixes #29 - Updated examples/simple_instance/main.tf with adding hashed image into instance_name - Updated examples/simple_instance/outputs.tf with adding hashed image into instance_name --- examples/simple_instance/main.tf | 8 ++++++-- examples/simple_instance/outputs.tf | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/simple_instance/main.tf b/examples/simple_instance/main.tf index c987df1..fdf6970 100644 --- a/examples/simple_instance/main.tf +++ b/examples/simple_instance/main.tf @@ -18,6 +18,10 @@ provider "google" { region = var.region } +locals { + instance_name = format("%s-%s", var.instance_name, md5(module.gce-container.container.image)) +} + data "google_compute_zones" "available" { project = var.project_id region = var.region @@ -32,7 +36,7 @@ module "gce-container" { source = "../../" container = { - image = "gcr.io/google-samples/hello-app:1.0" + image = "gcr.io/google-samples/hello-app:2.0" env = [ { @@ -65,7 +69,7 @@ module "gce-container" { resource "google_compute_instance" "vm" { project = var.project_id - name = var.instance_name + name = local.instance_name machine_type = "n1-standard-1" zone = random_shuffle.zone.result[0] diff --git a/examples/simple_instance/outputs.tf b/examples/simple_instance/outputs.tf index b2b68c1..7ae72b4 100644 --- a/examples/simple_instance/outputs.tf +++ b/examples/simple_instance/outputs.tf @@ -41,7 +41,7 @@ output "volumes" { output "instance_name" { description = "The deployed instance name" - value = var.instance_name + value = local.instance_name } output "ipv4" {