blob: 0128c4df2d80d55e73c48cd22fe8153c00757951 [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Cloud Source Repositories"
description: |-
A repository (or repo) is a Git repository storing versioned source content.
---
# google\_sourcerepo\_repository
A repository (or repo) is a Git repository storing versioned source content.
To get more information about Repository, see:
* [API documentation](https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos)
* How-to Guides
* [Official Documentation](https://cloud.google.com/source-repositories/)
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=sourcerepo_repository_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Sourcerepo Repository Basic
```hcl
resource "google_sourcerepo_repository" "my-repo" {
name = "my/repository"
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=sourcerepo_repository_full&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Sourcerepo Repository Full
```hcl
resource "google_service_account" "test_account" {
account_id = "my-account"
display_name = "Test Service Account"
}
resource "google_pubsub_topic" "topic" {
name = "my-topic"
}
resource "google_sourcerepo_repository" "my-repo" {
name = "my-repository"
pubsub_configs {
topic = google_pubsub_topic.topic.id
message_format = "JSON"
service_account_email = google_service_account.test_account.email
}
}
```
## Argument Reference
The following arguments are supported:
* `name` -
(Required)
Resource name of the repository, of the form `{{repo}}`.
The repo name may contain slashes. eg, `name/with/slash`
- - -
* `pubsub_configs` -
(Optional)
How this repository publishes a change in the repository through Cloud Pub/Sub.
Keyed by the topic names.
Structure is [documented below](#nested_pubsub_configs).
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
<a name="nested_pubsub_configs"></a>The `pubsub_configs` block supports:
* `topic` - (Required) The identifier for this object. Format specified above.
* `message_format` -
(Required)
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 are: `PROTOBUF`, `JSON`.
* `service_account_email` -
(Optional)
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.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `projects/{{project}}/repos/{{name}}`
* `url` -
URL to clone the repository from Google Cloud Source Repositories.
* `size` -
The disk usage of the repo, in bytes.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## Import
Repository can be imported using any of these accepted formats:
* `projects/{{project}}/repos/{{name}}`
* `{{name}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Repository using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/repos/{{name}}"
to = google_sourcerepo_repository.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Repository can be imported using one of the formats above. For example:
```
$ terraform import google_sourcerepo_repository.default projects/{{project}}/repos/{{name}}
$ terraform import google_sourcerepo_repository.default {{name}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).