blob: 0a14cd211f33f6079a695566de28cfdcaa0c53e2 [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 Build"
description: |-
BitbucketServerConfig represents the configuration for a Bitbucket Server.
---
# google\_cloudbuild\_bitbucket\_server\_config
BitbucketServerConfig represents the configuration for a Bitbucket Server.
To get more information about BitbucketServerConfig, see:
* [API documentation](https://cloud.google.com/build/docs/api/reference/rest/v1/projects.locations.bitbucketServerConfigs)
* How-to Guides
* [Connect to a Bitbucket Server host](https://cloud.google.com/build/docs/automating-builds/bitbucket/connect-host-bitbucket-server)
<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=cloudbuild_bitbucket_server_config&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 - Cloudbuild Bitbucket Server Config
```hcl
resource "google_cloudbuild_bitbucket_server_config" "bbs-config" {
config_id = "bbs-config"
location = "us-central1"
host_uri = "https://bbs.com"
secrets {
admin_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
read_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
webhook_secret_version_name = "projects/myProject/secrets/mybbspat/versions/1"
}
username = "test"
api_key = "<api-key>"
}
```
## Example Usage - Cloudbuild Bitbucket Server Config Repositories
```hcl
resource "google_cloudbuild_bitbucket_server_config" "bbs-config-with-repos" {
config_id = "bbs-config"
location = "us-central1"
host_uri = "https://bbs.com"
secrets {
admin_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
read_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
webhook_secret_version_name = "projects/myProject/secrets/mybbspat/versions/1"
}
username = "test"
api_key = "<api-key>"
connected_repositories {
project_key = "DEV"
repo_slug = "repo1"
}
connected_repositories {
project_key = "PROD"
repo_slug = "repo1"
}
}
```
<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=cloudbuild_bitbucket_server_config_peered_network&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 - Cloudbuild Bitbucket Server Config Peered Network
```hcl
data "google_project" "project" {}
resource "google_project_service" "servicenetworking" {
service = "servicenetworking.googleapis.com"
disable_on_destroy = false
}
resource "google_compute_network" "vpc_network" {
name = "vpc-network"
depends_on = [google_project_service.servicenetworking]
}
resource "google_compute_global_address" "private_ip_alloc" {
name = "private-ip-alloc"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = google_compute_network.vpc_network.id
}
resource "google_service_networking_connection" "default" {
network = google_compute_network.vpc_network.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
depends_on = [google_project_service.servicenetworking]
}
resource "google_cloudbuild_bitbucket_server_config" "bbs-config-with-peered-network" {
config_id = "bbs-config"
location = "us-central1"
host_uri = "https://bbs.com"
secrets {
admin_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
read_access_token_version_name = "projects/myProject/secrets/mybbspat/versions/1"
webhook_secret_version_name = "projects/myProject/secrets/mybbspat/versions/1"
}
username = "test"
api_key = "<api-key>"
peered_network = replace(google_compute_network.vpc_network.id, data.google_project.project.name, data.google_project.project.number)
ssl_ca = "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----\n"
depends_on = [google_service_networking_connection.default]
}
```
## Argument Reference
The following arguments are supported:
* `host_uri` -
(Required)
Immutable. The URI of the Bitbucket Server host. Once this field has been set, it cannot be changed.
If you need to change it, please create another BitbucketServerConfig.
* `secrets` -
(Required)
Secret Manager secrets needed by the config.
Structure is [documented below](#nested_secrets).
* `username` -
(Required)
Username of the account Cloud Build will use on Bitbucket Server.
* `api_key` -
(Required)
Immutable. API Key that will be attached to webhook. Once this field has been set, it cannot be changed.
Changing this field will result in deleting/ recreating the resource.
* `config_id` -
(Required)
The ID to use for the BitbucketServerConfig, which will become the final component of the BitbucketServerConfig's resource name.
* `location` -
(Required)
The location of this bitbucket server config.
<a name="nested_secrets"></a>The `secrets` block supports:
* `admin_access_token_version_name` -
(Required)
The resource name for the admin access token's secret version.
* `read_access_token_version_name` -
(Required)
The resource name for the read access token's secret version.
* `webhook_secret_version_name` -
(Required)
Immutable. The resource name for the webhook secret's secret version. Once this field has been set, it cannot be changed.
Changing this field will result in deleting/ recreating the resource.
- - -
* `connected_repositories` -
(Optional)
Connected Bitbucket Server repositories for this config.
Structure is [documented below](#nested_connected_repositories).
* `peered_network` -
(Optional)
The network to be used when reaching out to the Bitbucket Server instance. The VPC network must be enabled for private service connection.
This should be set if the Bitbucket Server instance is hosted on-premises and not reachable by public internet. If this field is left empty,
no network peering will occur and calls to the Bitbucket Server instance will be made over the public internet. Must be in the format
projects/{project}/global/networks/{network}, where {project} is a project number or id and {network} is the name of a VPC network in the project.
* `ssl_ca` -
(Optional)
SSL certificate to use for requests to Bitbucket Server. The format should be PEM format but the extension can be one of .pem, .cer, or .crt.
* `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_connected_repositories"></a>The `connected_repositories` block supports:
* `project_key` -
(Required)
Identifier for the project storing the repository.
* `repo_slug` -
(Required)
Identifier for the repository.
## 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}}/locations/{{location}}/bitbucketServerConfigs/{{config_id}}`
* `name` -
The resource name for the config.
* `webhook_key` -
Output only. UUID included in webhook requests. The UUID is used to look up the corresponding config.
## 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
BitbucketServerConfig can be imported using any of these accepted formats:
* `projects/{{project}}/locations/{{location}}/bitbucketServerConfigs/{{config_id}}`
* `{{project}}/{{location}}/{{config_id}}`
* `{{location}}/{{config_id}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import BitbucketServerConfig using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/locations/{{location}}/bitbucketServerConfigs/{{config_id}}"
to = google_cloudbuild_bitbucket_server_config.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), BitbucketServerConfig can be imported using one of the formats above. For example:
```
$ terraform import google_cloudbuild_bitbucket_server_config.default projects/{{project}}/locations/{{location}}/bitbucketServerConfigs/{{config_id}}
$ terraform import google_cloudbuild_bitbucket_server_config.default {{project}}/{{location}}/{{config_id}}
$ terraform import google_cloudbuild_bitbucket_server_config.default {{location}}/{{config_id}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).