Skip to content

Commit ebbb80b

Browse files
author
Simon So
committed
Update tests and project_services submodule
1 parent 529ea6a commit ebbb80b

File tree

17 files changed

+83
-269
lines changed

17 files changed

+83
-269
lines changed

examples/instance_template/simple/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ module "instance_template" {
2626
subnetwork = "${var.subnetwork}"
2727
service_account = "${var.service_account}"
2828
name_prefix = "simple"
29+
tags = "${var.tags}"
30+
labels = "${var.labels}"
2931
}

examples/instance_template/simple/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@ variable "service_account" {
3535
type = "map"
3636
description = "Service account email address and scopes"
3737
}
38+
39+
variable "tags" {
40+
type = "list"
41+
description = "Network tags, provided as a list"
42+
}
43+
44+
variable "labels" {
45+
type = "map"
46+
description = "Labels, provided as a map"
47+
}

examples/mig/autoscaler/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ module "instance_template" {
3232
source = "../../../modules/instance_template"
3333
subnetwork = "${var.subnetwork}"
3434
service_account = "${var.service_account}"
35-
tags = "${var.tags}"
36-
labels = "${var.labels}"
3735
}
3836

3937
module "mig" {

examples/mig/autoscaler/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ variable "service_account" {
3535
description = "Service account email address and scopes"
3636
}
3737

38-
variable "tags" {
39-
type = "list"
40-
description = "Network tags, provided as a list"
41-
}
42-
43-
variable "labels" {
44-
type = "map"
45-
description = "Labels, provided as a map"
46-
}
47-
4838
variable "autoscaling_enabled" {
4939
description = "Creates an autoscaler for the managed instance group"
5040
}

examples/mig/simple/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ module "instance_template" {
3232
source = "../../../modules/instance_template"
3333
subnetwork = "${var.subnetwork}"
3434
service_account = "${var.service_account}"
35-
tags = "${var.tags}"
36-
labels = "${var.labels}"
3735
}
3836

3937
module "mig" {

examples/mig/simple/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ variable "subnetwork" {
3030
description = "The subnetwork to host the compute instances in"
3131
}
3232

33-
variable "tags" {
34-
type = "list"
35-
description = "Network tags, provided as a list"
36-
}
37-
38-
variable "labels" {
39-
type = "map"
40-
description = "Labels, provided as a map"
41-
}
42-
4333
variable "target_size" {
4434
description = "The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set."
4535
}

modules/mig/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
output "self_link" {
1818
description = "Self-link of managed instance group"
19-
value = "${element(coalescelist(google_compute_region_instance_group_manager.mig.*.self_link, list("")),0)}"
19+
value = "${google_compute_region_instance_group_manager.mig.self_link}"
2020
}

modules/project_services/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
APIs configuration
1919
*****************************************/
2020
resource "google_project_service" "project_services" {
21-
count = "${length(var.activate_apis)}"
22-
project = "${var.project_id}"
23-
service = "${element(var.activate_apis, count.index)}"
21+
count = "${var.enable_apis ? length(var.activate_apis) : 0}"
22+
project = "${var.project_id}"
23+
service = "${element(var.activate_apis, count.index)}"
24+
disable_on_destroy = "${var.disable_services_on_destroy}"
2425
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2018 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 "project_id" {
18+
description = "The GCP project you want to enable APIs on"
19+
value = "${var.project_id}"
20+
}

modules/project_services/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ variable "project_id" {
1818
description = "The GCP project you want to enable APIs on"
1919
}
2020

21+
variable "enable_apis" {
22+
description = "Whether to actually enable the APIs. If false, this module is a no-op."
23+
default = "true"
24+
}
25+
2126
variable "activate_apis" {
2227
description = "The list of apis to activate within the project"
2328
type = "list"
@@ -27,3 +32,9 @@ variable "activate_apis" {
2732
"iam.googleapis.com",
2833
]
2934
}
35+
36+
variable "disable_services_on_destroy" {
37+
description = "Whether project services will be disabled when the resources are destroyed. https://www.terraform.io/docs/providers/google/r/google_project_service.html#disable_on_destroy"
38+
default = "true"
39+
type = "string"
40+
}

0 commit comments

Comments
 (0)