diff --git a/modules/services/main.tf b/modules/services/main.tf new file mode 100644 index 000000000..f6021fe1a --- /dev/null +++ b/modules/services/main.tf @@ -0,0 +1,31 @@ +/** + * 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 = "~> 6.0.0" + + 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", + "iam.googleapis.com", + "container.googleapis.com" + ] +} diff --git a/modules/services/outputs.tf b/modules/services/outputs.tf new file mode 100644 index 000000000..7c1ea4439 --- /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 000000000..53d78e55b --- /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 +}