Google Cloud Platform Project Service
This page shows how to write Terraform for Cloud Platform Project Service and write them securely.
google_project_service (Terraform)
The Project Service in Cloud Platform can be configured in Terraform with the resource name google_project_service
. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_project_service" "run" {
service = "run.googleapis.com"
disable_on_destroy = false
}
resource "google_project_service" "cloudkms" {
resource "google_project_service" "gcp_resource_manager_api" {
service = "cloudresourcemanager.googleapis.com"
project = var.project
disable_dependent_services = false
disable_on_destroy = false
}
resource "google_project_service" "logging" {
project = var.gcp_project_id
service = "logging.googleapis.com"
disable_dependent_services = true
}
Parameters
-
disable_dependent_services
optional - bool -
disable_on_destroy
optional - bool -
id
optional computed - string -
project
optional computed - string -
service
required - string -
timeouts
single block
Explanation in Terraform Registry
Allows management of a single API service for a Google Cloud Platform project. For a list of services available, visit the API library page or run
gcloud services list --available
. This resource requires the Service Usage API to use. To get more information aboutgoogle_project_service
, see:
- API documentation
- How-to Guides
Tips: Best Practices for The Other Google Cloud Platform Resources
In addition to the google_project, Google Cloud Platform has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
google_project
Ensure project-level default network creation is disabled
It is better to disable the auto-creation of default networks. The default network for a GCP project is usually configured coarsely, leaving the risk of unwanted access to resources in the network.
Frequently asked questions
What is Google Cloud Platform Project Service?
Google Cloud Platform Project Service is a resource for Cloud Platform of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google Cloud Platform Project Service?
For Terraform, the binxio/authority-contribution-scraper, LaurensVijnck/speech-api and relaycorp/cloud-gateway source code examples are useful. See the Terraform Example section for further details.