Skip to content

Commit 658ea51

Browse files
authored
feat: Add a service activation module (terraform-google-modules#146)
* Start a service activation module * Complete proejct services submodule * Pass through variables
1 parent e4abe78 commit 658ea51

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

modules/services/main.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
module "services" {
18+
source = "terraform-google-modules/project-factory/google//modules/project_services"
19+
version = "~> 6.0.0"
20+
21+
project_id = var.project_id
22+
enable_apis = var.enable_apis
23+
disable_services_on_destroy = var.disable_services_on_destroy
24+
disable_dependent_services = var.disable_dependent_services
25+
26+
activate_apis = [
27+
"compute.googleapis.com",
28+
"iam.googleapis.com",
29+
"container.googleapis.com"
30+
]
31+
}

modules/services/outputs.tf

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 enabled APIs on"
19+
value = module.services.project_id
20+
}

modules/services/variables.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
variable "project_id" {
18+
description = "The GCP project you want to enable APIs on"
19+
type = string
20+
}
21+
22+
variable "enable_apis" {
23+
description = "Whether to actually enable the APIs. If false, this module is a no-op."
24+
default = true
25+
type = bool
26+
}
27+
28+
variable "disable_services_on_destroy" {
29+
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"
30+
default = false
31+
type = bool
32+
}
33+
34+
variable "disable_dependent_services" {
35+
description = "Whether services that are enabled and which depend on this service should also be disabled when this service is destroyed. https://www.terraform.io/docs/providers/google/r/google_project_service.html#disable_dependent_services"
36+
default = false
37+
type = bool
38+
}

0 commit comments

Comments
 (0)