Skip to content

Commit

Permalink
alloydb backup
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn committed Nov 23, 2022
1 parent 19073c2 commit 536c590
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 2 deletions.
103 changes: 102 additions & 1 deletion mmv1/products/alloydb/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,105 @@ objects:
- !ruby/object:Api::Type::Integer
name: "cpuCount"
input: true
description: "The number of CPU's in the VM instance."
description: "The number of CPU's in the VM instance."
- !ruby/object:Api::Resource
name: "Backup"
self_link: "projects/{{project}}/locations/{{location}}/backups/{{backup_id}}"
base_url: "projects/{{project}}/locations/{{location}}/backups"
create_url: "projects/{{project}}/locations/{{location}}/backups?backupId={{backup_id}}"
update_verb: :PATCH
update_mask: true
min_version: beta
description: "An AlloyDB Backup."
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
"AlloyDB": "https://cloud.google.com/alloydb/docs/"
api: "https://cloud.google.com/alloydb/docs/reference/rest/v1beta/projects.locations.backups/create"
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: "name"
base_url: "{{op_id}}"
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 10
update_minutes: 10
delete_minutes: 10
result: !ruby/object:Api::OpAsync::Result
path: "response"
status: !ruby/object:Api::OpAsync::Status
path: "done"
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: "error"
message: "message"
parameters:
- !ruby/object:Api::Type::String
name: "backupId"
required: true
input: true
url_param_only: true
description: |
The ID of the alloydb backup.
- !ruby/object:Api::Type::String
name: "location"
input: true
url_param_only: true
description: |
The location where the alloydb backup should reside.
properties:
- !ruby/object:Api::Type::String
name: "name"
output: true
description: |
Output only. The name of the backup resource with the format: * projects/{project}/locations/{region}/backups/{backupId}
- !ruby/object:Api::Type::String
name: "uid"
output: true
description: |
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.
- !ruby/object:Api::Type::String
name: "clusterName"
description: "The full resource name of the backup source cluster (e.g., projects/{project}/locations/{location}/clusters/{clusterId})."
required: true
- !ruby/object:Api::Type::KeyValuePairs
name: "labels"
description: "User-defined labels for the alloydb backup."
- !ruby/object:Api::Type::String
name: "displayName"
description: |
User-settable and human-readable display name for the Backup.
- !ruby/object:Api::Type::Time
name: "createTime"
description: |
Time the Backup was created in UTC.
output: true
- !ruby/object:Api::Type::Time
name: "updateTime"
description: |
Time the Backup was updated in UTC.
output: true
- !ruby/object:Api::Type::String
name: "state"
output: true
description: |
The current state of the backup.
- !ruby/object:Api::Type::String
name: "description"
description: |
User-provided description of the backup.
- !ruby/object:Api::Type::Boolean
name: "reconciling"
output: true
description: |
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.
- !ruby/object:Api::Type::String
name: 'etag'
description: |
A hash of the resource.
output: true
- !ruby/object:Api::Type::KeyValuePairs
name: "annotations"
description: "Annotations to allow client tools to store small amount of arbitrary data. This is distinct from labels."
27 changes: 26 additions & 1 deletion mmv1/products/alloydb/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
ignore_read: true
initialUser.password: !ruby/object:Overrides::Terraform::PropertyOverride
sensitive: true
network: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: "projectNumberDiffSuppress"
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
Expand Down Expand Up @@ -58,4 +60,27 @@ overrides: !ruby/object:Overrides::ResourceOverrides
alloydb_instance_name: "alloydb-instance"
ignore_read_extra:
- "reconciling"
- "update_time"
- "update_time"
Backup: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ["projects/{{project}}/locations/{{location}}/backups/{{backup_id}}"]
autogen_async: true
properties:
clusterName: !ruby/object:Overrides::Terraform::PropertyOverride
diff_suppress_func: "projectNumberDiffSuppress"
examples:
- !ruby/object:Provider::Terraform::Examples
name: "alloydb_backup_basic"
min_version: beta
primary_resource_id: "default"
vars:
alloydb_backup_id: "alloydb-backup"
alloydb_cluster_name: "alloydb-cluster"
alloydb_instance_name: "alloydb-instance"
network_name: "alloydb-network"
test_vars_overrides:
network_name: 'BootstrapSharedTestNetwork(t, "alloydb")'
ignore_read_extra:
- "reconciling"
- "update_time"
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: templates/terraform/encoders/alloydb_backup.erb
3 changes: 3 additions & 0 deletions mmv1/templates/terraform/encoders/alloydb_backup.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// The only other available type is AUTOMATED which cannot be set manually
obj["type"] = "ON_DEMAND"
return obj, nil
46 changes: 46 additions & 0 deletions mmv1/templates/terraform/examples/alloydb_backup_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
resource "google_alloydb_backup" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
location = "us-central1"
backup_id = "<%= ctx[:vars]['alloydb_backup_id'] %>"
cluster_name = google_alloydb_cluster.<%= ctx[:primary_resource_id] %>.name

depends_on = [google_alloydb_instance.<%= ctx[:primary_resource_id] %>]
}

resource "google_alloydb_cluster" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
cluster_id = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
location = "us-central1"
network = data.google_compute_network.default.id
}

resource "google_alloydb_instance" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
cluster = google_alloydb_cluster.<%= ctx[:primary_resource_id] %>.name
instance_id = "<%= ctx[:vars]['alloydb_instance_name'] %>"
instance_type = "PRIMARY"

depends_on = [google_service_networking_connection.vpc_connection]
}

resource "google_compute_global_address" "private_ip_alloc" {
provider = google-beta
name = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
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 = "<%= ctx[:vars]['network_name'] %>"
}

0 comments on commit 536c590

Please sign in to comment.