Google Cloud Source Repositories Repository

This page shows how to write Terraform for Cloud Source Repositories Repository and write them securely.

google_sourcerepo_repository (Terraform)

The Repository in Cloud Source Repositories can be configured in Terraform with the resource name google_sourcerepo_repository. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

build.tf#L1
resource "google_sourcerepo_repository" "machine_image" {
  name = "machine-image"
  depends_on = [ var.sourcerepo_service ]
}

resource "google_sourcerepo_repository" "packer_builder" {
main.tf#L1
resource "google_sourcerepo_repository" "sourcerepo" {
  name = "webserver"
}
repos.tf#L1
resource "google_sourcerepo_repository" "dotfiles" {
  name = "dotfiles"
}
repo.tf#L1
resource "google_sourcerepo_repository" "code-repo" {
  count = var.envname == "dev" ? 1 : 0

  name = var.repo_name
}

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

  • id optional computed - string
  • name required - string

Resource name of the repository, of the form '[[repo]]'. The repo name may contain slashes. eg, 'name/with/slash'

  • project optional computed - string
  • size optional computed - number

The disk usage of the repo, in bytes.

  • url optional computed - string

URL to clone the repository from Google Cloud Source Repositories.

  • pubsub_configs set block

    The format of the Cloud Pub/Sub messages. - PROTOBUF: The message payload is a serialized protocol buffer of SourceRepoEvent. - JSON: The message payload is a JSON string of SourceRepoEvent. Possible values: ["PROTOBUF", "JSON"]

    Email address of the service account used for publishing Cloud Pub/Sub messages. This service account needs to be in the same project as the PubsubConfig. When added, the caller needs to have iam.serviceAccounts.actAs permission on this service account. If unspecified, it defaults to the compute engine default service account.

  • timeouts single block

Explanation in Terraform Registry

A repository (or repo) is a Git repository storing versioned source content. To get more information about Repository, see:

Frequently asked questions

What is Google Cloud Source Repositories Repository?

Google Cloud Source Repositories Repository is a resource for Cloud Source Repositories of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Cloud Source Repositories Repository?

For Terraform, the syntapy/gce-img-builder, mikaelvesavuori/node-simple-webserver-gcp-terraform and jonpulsifer/cloudlab 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.