From 0594ec03ad858d14c8d269fae564c6dd21c6d48a Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Thu, 25 Apr 2019 19:49:38 -0400 Subject: [PATCH 1/3] Start a service activation module --- modules/services/main.tf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 modules/services/main.tf diff --git a/modules/services/main.tf b/modules/services/main.tf new file mode 100644 index 0000000000..daf1bc87fd --- /dev/null +++ b/modules/services/main.tf @@ -0,0 +1,12 @@ +module "project-services" { + source = "terraform-google-modules/project-factory/google//modules/project_services" + version = "2.1.3" + + project_id = "morgantep-gke-test-project" + + activate_apis = [ + "compute.googleapis.com", + "iam.googleapis.com", + "container.googleapis.com" + ] +} From 2f9b5a47a59c2d3fef6e9f9cb3b8227a5aff7686 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Mon, 9 Dec 2019 14:37:13 -0500 Subject: [PATCH 2/3] Complete proejct services submodule --- modules/services/main.tf | 22 +++++++++++++++++--- modules/services/outputs.tf | 20 ++++++++++++++++++ modules/services/variables.tf | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 modules/services/outputs.tf create mode 100644 modules/services/variables.tf diff --git a/modules/services/main.tf b/modules/services/main.tf index daf1bc87fd..c9b29ce979 100644 --- a/modules/services/main.tf +++ b/modules/services/main.tf @@ -1,8 +1,24 @@ -module "project-services" { +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module "services" { source = "terraform-google-modules/project-factory/google//modules/project_services" - version = "2.1.3" + version = "~> 6.0.0" - project_id = "morgantep-gke-test-project" + project_id = var.project_id activate_apis = [ "compute.googleapis.com", diff --git a/modules/services/outputs.tf b/modules/services/outputs.tf new file mode 100644 index 0000000000..7c1ea44392 --- /dev/null +++ b/modules/services/outputs.tf @@ -0,0 +1,20 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +output "project_id" { + description = "The GCP project you enabled APIs on" + value = module.services.project_id +} diff --git a/modules/services/variables.tf b/modules/services/variables.tf new file mode 100644 index 0000000000..53d78e55b4 --- /dev/null +++ b/modules/services/variables.tf @@ -0,0 +1,38 @@ +/** + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +variable "project_id" { + description = "The GCP project you want to enable APIs on" + type = string +} + +variable "enable_apis" { + description = "Whether to actually enable the APIs. If false, this module is a no-op." + default = true + type = bool +} + +variable "disable_services_on_destroy" { + 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" + default = false + type = bool +} + +variable "disable_dependent_services" { + 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" + default = false + type = bool +} From cecdcddc8c1bf17dd2225f5048e038d4b3bbad1c Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Mon, 9 Dec 2019 14:38:33 -0500 Subject: [PATCH 3/3] Pass through variables --- modules/services/main.tf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/services/main.tf b/modules/services/main.tf index c9b29ce979..f6021fe1a8 100644 --- a/modules/services/main.tf +++ b/modules/services/main.tf @@ -18,7 +18,10 @@ module "services" { source = "terraform-google-modules/project-factory/google//modules/project_services" version = "~> 6.0.0" - project_id = var.project_id + project_id = var.project_id + enable_apis = var.enable_apis + disable_services_on_destroy = var.disable_services_on_destroy + disable_dependent_services = var.disable_dependent_services activate_apis = [ "compute.googleapis.com",