A repository associated to a parent connection.
To get more information about Repository, see:
resource "google_secret_manager_secret" "private-key-secret" {
secret_id = "ghe-pk-secret"
replication {
auto {}
}
}
resource "google_secret_manager_secret_version" "private-key-secret-version" {
secret = google_secret_manager_secret.private-key-secret.id
secret_data = file("private-key.pem")
}
resource "google_secret_manager_secret" "webhook-secret-secret" {
secret_id = "github-token-secret"
replication {
auto {}
}
}
resource "google_secret_manager_secret_version" "webhook-secret-secret-version" {
secret = google_secret_manager_secret.webhook-secret-secret.id
secret_data = "<webhook-secret-data>"
}
data "google_iam_policy" "p4sa-secretAccessor" {
binding {
role = "roles/secretmanager.secretAccessor"
// Here, 123456789 is the Google Cloud project number for the project that contains the connection.
members = ["serviceAccount:service-123456789@gcp-sa-cloudbuild.iam.gserviceaccount.com"]
}
}
resource "google_secret_manager_secret_iam_policy" "policy-pk" {
secret_id = google_secret_manager_secret.private-key-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}
resource "google_secret_manager_secret_iam_policy" "policy-whs" {
secret_id = google_secret_manager_secret.webhook-secret-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}
resource "google_cloudbuildv2_connection" "my-connection" {
location = "us-central1"
name = "my-terraform-ghe-connection"
github_enterprise_config {
host_uri = "https://ghe.com"
private_key_secret_version = google_secret_manager_secret_version.private-key-secret-version.id
webhook_secret_secret_version = google_secret_manager_secret_version.webhook-secret-secret-version.id
app_id = 200
app_slug = "gcb-app"
app_installation_id = 300
}
depends_on = [
google_secret_manager_secret_iam_policy.policy-pk,
google_secret_manager_secret_iam_policy.policy-whs
]
}
resource "google_cloudbuildv2_repository" "my-repository" {
name = "my-terraform-ghe-repo"
location = "us-central1"
parent_connection = google_cloudbuildv2_connection.my-connection.id
remote_uri = "https://ghe.com/hashicorp/terraform-provider-google.git"
}
resource "google_secret_manager_secret" "github-token-secret" {
secret_id = "github-token-secret"
replication {
auto {}
}
}
resource "google_secret_manager_secret_version" "github-token-secret-version" {
secret = google_secret_manager_secret.github-token-secret.id
secret_data = file("my-github-token.txt")
}
data "google_iam_policy" "p4sa-secretAccessor" {
binding {
role = "roles/secretmanager.secretAccessor"
// Here, 123456789 is the Google Cloud project number for the project that contains the connection.
members = ["serviceAccount:service-123456789@gcp-sa-cloudbuild.iam.gserviceaccount.com"]
}
}
resource "google_secret_manager_secret_iam_policy" "policy" {
secret_id = google_secret_manager_secret.github-token-secret.secret_id
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
}
resource "google_cloudbuildv2_connection" "my-connection" {
location = "us-central1"
name = "my-connection"
github_config {
app_installation_id = 123123
authorizer_credential {
oauth_token_secret_version = google_secret_manager_secret_version.github-token-secret-version.id
}
}
}
resource "google_cloudbuildv2_repository" "my-repository" {
location = "us-central1"
name = "my-repo"
parent_connection = google_cloudbuildv2_connection.my-connection.name
remote_uri = "https://github.com/myuser/myrepo.git"
}
The following arguments are supported:
name
-
(Required)
Name of the repository.
remote_uri
-
(Required)
Required. Git Clone HTTPS URI.
parent_connection
-
(Required)
The connection for the resource
annotations
-
(Optional)
Allows clients to store small amounts of arbitrary data.
Note: This field is non-authoritative, and will only manage the annotations present in your configuration.
Please refer to the field effective_annotations
for all of the annotations present on the resource.
location
-
(Optional)
The location for the resource
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/repositories/{{name}}
create_time
-
Output only. Server assigned timestamp for when the connection was created.
update_time
-
Output only. Server assigned timestamp for when the connection was updated.
etag
-
This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
effective_annotations
-
All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services.
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.delete
- Default is 20 minutes.Repository can be imported using any of these accepted formats:
projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/repositories/{{name}}
{{project}}/{{location}}/{{parent_connection}}/{{name}}
{{location}}/{{parent_connection}}/{{name}}
In Terraform v1.5.0 and later, use an import
block to import Repository using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/repositories/{{name}}"
to = google_cloudbuildv2_repository.default
}
When using the terraform import
command, Repository can be imported using one of the formats above. For example:
$ terraform import google_cloudbuildv2_repository.default projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/repositories/{{name}}
$ terraform import google_cloudbuildv2_repository.default {{project}}/{{location}}/{{parent_connection}}/{{name}}
$ terraform import google_cloudbuildv2_repository.default {{location}}/{{parent_connection}}/{{name}}
This resource supports User Project Overrides.