Google Cloud Source Repositories Repository

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


Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.


Terraform Example (google_sourcerepo_repository)

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


  • id optionalcomputed - string
  • name required - string
    • Resource name of the repository, of the form '{{repo}}'. The repo name may contain slashes. eg, 'name/with/slash'

  • project optionalcomputed - string
  • size requiredcomputed - number
    • The disk usage of the repo, in bytes.

  • url requiredcomputed - string
    • URL to clone the repository from Google Cloud Source Repositories.

Example Usage (from GitHub)

resource "google_sourcerepo_repository" "machine_image" {
  name = "machine-image"
  depends_on = [ var.sourcerepo_service ]

resource "google_sourcerepo_repository" "packer_builder" {
resource "google_sourcerepo_repository" "sourcerepo" {
  name = "webserver"
resource "google_sourcerepo_repository" "dotfiles" {
  name = "dotfiles"
resource "google_sourcerepo_repository" "code-repo" {
  count = var.envname == "dev" ? 1 : 0

  name = var.repo_name

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.