Skip to content

Commit

Permalink
feat: Add a service activation module (#146)
Browse files Browse the repository at this point in the history
* Start a service activation module

* Complete proejct services submodule

* Pass through variables
  • Loading branch information
morgante committed Jan 23, 2020
1 parent e4abe78 commit 658ea51
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
31 changes: 31 additions & 0 deletions modules/services/main.tf
Original file line number Diff line number Diff line change
@@ -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"
]
}
20 changes: 20 additions & 0 deletions modules/services/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
38 changes: 38 additions & 0 deletions modules/services/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 658ea51

Please sign in to comment.