From b8d871584b674354146ec71d7f9f94b1c1ec6d27 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 8 Dec 2022 20:33:31 +0000 Subject: [PATCH] alloydb backup (#6866) Closes https://github.com/hashicorp/terraform-provider-google/issues/11754 Signed-off-by: Modular Magician --- .changelog/6866.txt | 3 + .goreleaser.yml | 2 +- google/resource_alloydb_backup_test.go | 1 + website/docs/r/alloydb_backup.html.markdown | 177 ++++++++++++++++++++ 4 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 .changelog/6866.txt create mode 100644 google/resource_alloydb_backup_test.go create mode 100644 website/docs/r/alloydb_backup.html.markdown diff --git a/.changelog/6866.txt b/.changelog/6866.txt new file mode 100644 index 00000000000..38eeb329563 --- /dev/null +++ b/.changelog/6866.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +`google_alloydb_backup` +``` diff --git a/.goreleaser.yml b/.goreleaser.yml index ce9cf6b1102..5b3a87eded1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -29,7 +29,7 @@ builds: - goarch: arm64 goos: windows ldflags: - - -s -w -X github.com/hashicorp/terraform-provider-google/version.ProviderVersion={{.Version}} + - -s -w -X version.ProviderVersion={{.Version}} mod_timestamp: '{{ .CommitTimestamp }}' checksum: extra_files: diff --git a/google/resource_alloydb_backup_test.go b/google/resource_alloydb_backup_test.go new file mode 100644 index 00000000000..71664db3c87 --- /dev/null +++ b/google/resource_alloydb_backup_test.go @@ -0,0 +1 @@ +package google diff --git a/website/docs/r/alloydb_backup.html.markdown b/website/docs/r/alloydb_backup.html.markdown new file mode 100644 index 00000000000..8b94199b572 --- /dev/null +++ b/website/docs/r/alloydb_backup.html.markdown @@ -0,0 +1,177 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: "AlloyDB" +page_title: "Google: google_alloydb_backup" +description: |- + An AlloyDB Backup. +--- + +# google\_alloydb\_backup + +An AlloyDB Backup. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about Backup, see: + +* [API documentation](https://cloud.google.com/alloydb/docs/reference/rest/v1beta/projects.locations.backups/create) +* How-to Guides + * [AlloyDB](https://cloud.google.com/alloydb/docs/) + + +## Example Usage - Alloydb Backup Full + + +```hcl +resource "google_alloydb_backup" "default" { + provider = google-beta + location = "us-central1" + backup_id = "alloydb-backup" + cluster_name = google_alloydb_cluster.default.name + + description = "example description" + labels = { + "label" = "key" + } + depends_on = [google_alloydb_instance.default] +} + +resource "google_alloydb_cluster" "default" { + provider = google-beta + cluster_id = "alloydb-cluster" + location = "us-central1" + network = data.google_compute_network.default.id +} + +resource "google_alloydb_instance" "default" { + provider = google-beta + cluster = google_alloydb_cluster.default.name + instance_id = "alloydb-instance" + instance_type = "PRIMARY" + + depends_on = [google_service_networking_connection.vpc_connection] +} + +resource "google_compute_global_address" "private_ip_alloc" { + provider = google-beta + name = "alloydb-cluster" + address_type = "INTERNAL" + purpose = "VPC_PEERING" + prefix_length = 16 + network = data.google_compute_network.default.id +} + +resource "google_service_networking_connection" "vpc_connection" { + provider = google-beta + network = data.google_compute_network.default.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] +} + +data "google_compute_network" "default" { + provider = google-beta + name = "alloydb-network" +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `cluster_name` - + (Required) + The full resource name of the backup source cluster (e.g., projects/{project}/locations/{location}/clusters/{clusterId}). + +* `backup_id` - + (Required) + The ID of the alloydb backup. + + +- - - + + +* `labels` - + (Optional) + User-defined labels for the alloydb backup. + +* `description` - + (Optional) + User-provided description of the backup. + +* `location` - + (Optional) + The location where the alloydb backup should reside. + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + +## 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}}/backups/{{backup_id}}` + +* `name` - + Output only. The name of the backup resource with the format: * projects/{project}/locations/{region}/backups/{backupId} + +* `uid` - + Output only. The system-generated UID of the resource. The UID is assigned when the resource is created, and it is retained until it is deleted. + +* `create_time` - + Time the Backup was created in UTC. + +* `update_time` - + Time the Backup was updated in UTC. + +* `state` - + The current state of the backup. + +* `reconciling` - + If true, indicates that the service is actively updating the resource. This can happen due to user-triggered updates or system actions like failover or maintenance. + +* `etag` - + A hash of the resource. + + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 10 minutes. +- `update` - Default is 10 minutes. +- `delete` - Default is 10 minutes. + +## Import + + +Backup can be imported using any of these accepted formats: + +``` +$ terraform import google_alloydb_backup.default projects/{{project}}/locations/{{location}}/backups/{{backup_id}} +$ terraform import google_alloydb_backup.default {{project}}/{{location}}/{{backup_id}} +$ terraform import google_alloydb_backup.default {{location}}/{{backup_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).