Skip to content

Commit 8607440

Browse files
committed
Use unique name for example compute instances
1 parent 490d393 commit 8607440

File tree

8 files changed

+57
-3
lines changed

8 files changed

+57
-3
lines changed

examples/automatic-labelling-from-localhost/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ resource "google_compute_instance" "main" {
8989
}
9090

9191
machine_type = "f1-micro"
92-
name = "unlabelled"
92+
name = "unlabelled-${random_pet.main.id}"
9393
zone = "${var.zone}"
9494

9595
network_interface = {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "compute_instance_name" {
18+
value = "${google_compute_instance.main.name}"
19+
description = "The name of the unlabelled Compute instance."
20+
}

examples/automatic-labelling-from-repository/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ resource "google_compute_instance" "main" {
118118
}
119119

120120
machine_type = "f1-micro"
121-
name = "unlabelled"
121+
name = "unlabelled-${random_pet.main.id}"
122122
zone = "${var.zone}"
123123

124124
network_interface = {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "compute_instance_name" {
18+
value = "${google_compute_instance.main.name}"
19+
description = "The name of the unlabelled Compute instance."
20+
}

test/fixtures/automatic-labelling-from-localhost/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
output "compute_instance_name" {
18+
value = "${module.automatic_labelling_from_localhost.compute_instance_name}"
19+
description = "The name of the unlabelled Compute instance."
20+
}
21+
1722
output "project_id" {
1823
value = "${var.project_id}"
1924
description = "The ID of the project to which resources are applied."

test/fixtures/automatic-labelling-from-repository/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
output "compute_instance_name" {
18+
value = "${module.automatic_labelling_from_repository.compute_instance_name}"
19+
description = "The name of the unlabelled Compute instance."
20+
}
21+
1722
output "project_id" {
1823
value = "${var.project_id}"
1924
description = "The ID of the project to which resources are applied."

test/integration/automatic-labelling/controls/automatically_labelled.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
describe google_compute_instance(
2121
project: attribute("project_id"),
2222
zone: attribute("zone"),
23-
name: "unlabelled",
23+
name: attribute("compute_instance_name"),
2424
) do
2525
let :principal_email do
2626
JSON.parse(File.read(ENV.fetch("GOOGLE_APPLICATION_CREDENTIALS"))).fetch("client_email").split("@").first

test/integration/automatic-labelling/inspec.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ depends:
2020
git: https://github.com/inspec/inspec-gcp.git
2121
tag: v0.10.0
2222
attributes:
23+
- name: compute_instance_name
24+
type: string
25+
required: true
26+
description: "The name of the unlabelled Compute instance."
2327
- name: project_id
2428
type: string
2529
required: true

0 commit comments

Comments
 (0)