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

services.tf#L2
resource "google_project_service" "run" {
  service            = "run.googleapis.com"
  disable_on_destroy = false
}

resource "google_project_service" "cloudkms" {
main.tf#L2
resource "google_project_service" "gcp_resource_manager_api" {
  service = "cloudresourcemanager.googleapis.com"
  project                    = var.project
  disable_dependent_services = false
  disable_on_destroy         = false
}
gcp.tf#L9
resource "google_project_service" "logging" {
  project                    = var.gcp_project_id
  service                    = "logging.googleapis.com"
  disable_dependent_services = true
}

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

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 about google_project_service, see:

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.

risk-label

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.

Review your Google Cloud Platform settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

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.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.