Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ivankorn committed Aug 9, 2019
1 parent becae96 commit dfc3d20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions examples/simple_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [
{
Expand Down Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_instance/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ output "volumes" {

output "instance_name" {
description = "The deployed instance name"
value = var.instance_name
value = local.instance_name
}

output "ipv4" {
Expand Down

0 comments on commit dfc3d20

Please sign in to comment.