Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alloydb cluster #6507

Merged
merged 45 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aa476df
basic resource + import
DrFaust92 Jul 1, 2022
e9ba718
add computed sources
DrFaust92 Jul 1, 2022
9ae0eb1
more args
DrFaust92 Jul 1, 2022
59a5cf8
fix network
DrFaust92 Jul 1, 2022
dd835d7
fix types for duration
DrFaust92 Jul 1, 2022
5f871c0
instance
DrFaust92 Jul 1, 2022
84936b6
Update mmv1/products/alloydb/api.yaml
DrFaust92 Jul 5, 2022
aacf190
Update mmv1/products/alloydb/api.yaml
DrFaust92 Jul 5, 2022
3f2b63c
Update mmv1/products/alloydb/api.yaml
DrFaust92 Jul 5, 2022
d80e451
create network for test
DrFaust92 Jul 7, 2022
a9ec2de
remove excludes + machineConfig
DrFaust92 Jul 7, 2022
56851e6
cluster_id
DrFaust92 Jul 7, 2022
dedc69c
cluster_id
DrFaust92 Jul 7, 2022
76e3030
revert
DrFaust92 Jul 9, 2022
08f3cbe
use parent resource
DrFaust92 Jul 9, 2022
298c537
use parent resource
DrFaust92 Jul 9, 2022
2032c72
add selflink
DrFaust92 Jul 9, 2022
84e064c
alloydb tests
DrFaust92 Jul 16, 2022
ef4b7c2
beta
DrFaust92 Jul 16, 2022
43187ee
import
DrFaust92 Jul 30, 2022
864612c
imports
DrFaust92 Jul 30, 2022
5ba488c
add conflicts
DrFaust92 Jul 30, 2022
085ac35
revert
DrFaust92 Jul 30, 2022
22b64ed
revert
DrFaust92 Jul 30, 2022
7952508
revert
DrFaust92 Jul 31, 2022
fcd58f1
revert
DrFaust92 Aug 2, 2022
17f77ac
Apply suggestions from code review
DrFaust92 Aug 12, 2022
54ae410
reduce only to cluster resource
DrFaust92 Sep 3, 2022
34f92da
Apply suggestions from code review
DrFaust92 Sep 14, 2022
487c70f
remove fields
DrFaust92 Sep 14, 2022
693f540
full example
DrFaust92 Sep 14, 2022
e5018dd
full test + validations
DrFaust92 Sep 14, 2022
e7c9646
Apply suggestions from code review
DrFaust92 Sep 15, 2022
ce0dc1e
remove unneeded arg
DrFaust92 Sep 17, 2022
f344ae5
CR - remove unspecified enums
DrFaust92 Sep 17, 2022
3b85f85
remove unneeded arg
DrFaust92 Sep 17, 2022
bd2d901
remove unneeded arg
DrFaust92 Sep 17, 2022
1cc0489
tests passing
DrFaust92 Sep 17, 2022
0721f88
Update mmv1/products/alloydb/api.yaml
DrFaust92 Sep 29, 2022
df94382
remove fields
DrFaust92 Sep 30, 2022
66ab54d
remove kms
DrFaust92 Oct 4, 2022
32ae518
remove kms
DrFaust92 Oct 4, 2022
c6a1aa0
fix rebase
DrFaust92 Oct 5, 2022
05caf4d
CR comments
DrFaust92 Oct 11, 2022
45d8b3e
CR comments
DrFaust92 Oct 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
238 changes: 238 additions & 0 deletions mmv1/products/alloydb/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# Copyright 2022 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
!ruby/object:Api::Product
name: Alloydb
display_name: AlloyDB
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://alloydb.googleapis.com/v1beta/
scopes:
- https://www.googleapis.com/auth/cloud-identity
apis_required:
- !ruby/object:Api::Product::ApiReference
name: AlloyDB API
url: https://console.cloud.google.com/apis/library/alloydb.googleapis.com
objects:
- !ruby/object:Api::Resource
name: "Cluster"
self_link: "projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}}"
base_url: "projects/{{project}}/locations/{{location}}/clusters"
create_url: "projects/{{project}}/locations/{{location}}/clusters?clusterId={{cluster_id}}"
update_verb: :PATCH
update_mask: true
min_version: beta
description: "A managed alloydb cluster."
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.clusters/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: "clusterId"
required: true
input: true
url_param_only: true
description: |
The ID of the alloydb cluster.
melinath marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::String
name: "location"
input: true
url_param_only: true
description: |
The location where the alloydb cluster should reside.
properties:
- !ruby/object:Api::Type::String
name: "name"
output: true
description: |
The name of the cluster resource.
- !ruby/object:Api::Type::String
name: "uid"
output: true
description: |
The system-generated UID of the resource.
- !ruby/object:Api::Type::KeyValuePairs
name: "labels"
description: "User-defined labels for the alloydb cluster."
- !ruby/object:Api::Type::String
name: "network"
required: true
description: |
The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form:

"projects/{projectNumber}/global/networks/{network_id}".
- !ruby/object:Api::Type::String
name: "displayName"
description: |
User-settable and human-readable display name for the Cluster.
- !ruby/object:Api::Type::String
name: "databaseVersion"
output: true
description: |
The database engine major version. This is an output-only field and it's populated at the Cluster creation time. This field cannot be changed after cluster creation.
- !ruby/object:Api::Type::NestedObject
name: "initialUser"
input: true
description: |
Initial user to setup during cluster creation.
properties:
- !ruby/object:Api::Type::String
name: "user"
description: |
The database username.
- !ruby/object:Api::Type::String
name: "password"
description: |
The initial password for the user.
required: true
melinath marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::NestedObject
name: "automatedBackupPolicy"
description: |
The automated backup policy for this cluster.

If no policy is provided then the default policy will be used. The default policy takes one backup a day, has a backup window of 1 hour, and retains backups for 14 days.
properties:
- !ruby/object:Api::Type::String
name: "backupWindow"
description: |
The length of the time window during which a backup can be taken. If a backup does not succeed within this time window, it will be canceled and considered failed.

The backup window must be at least 5 minutes long. There is no upper bound on the window. If not set, it will default to 1 hour.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
- !ruby/object:Api::Type::String
name: "location"
description: |
The location where the backup will be stored. Currently, the only supported option is to store the backup in the same region as the cluster.
- !ruby/object:Api::Type::KeyValuePairs
name: "labels"
description: "Labels to apply to backups created using this configuration."
- !ruby/object:Api::Type::NestedObject
name: "weeklySchedule"
input: true
required: true
description: "Weekly schedule for the Backup."
properties:
- !ruby/object:Api::Type::Array
name: "daysOfWeek"
min_size: 1
description: |
The days of the week to perform a backup. At least one day of the week must be provided.
item_type: !ruby/object:Api::Type::Enum
name: "daysOfWeek"
required: true
description: |
The days of the week to perform a backup. At least one day of the week must be provided.
values:
- :MONDAY
- :TUESDAY
- :WEDNESDAY
- :THURSDAY
- :FRIDAY
- :SATURDAY
- :SUNDAY
- !ruby/object:Api::Type::Array
name: "startTimes"
required: true
description: |
The times during the day to start a backup. At least one start time must be provided. The start times are assumed to be in UTC and to be an exact hour (e.g., 04:00:00).
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::Integer
name: hours
description: |
Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
- !ruby/object:Api::Type::Integer
name: minutes
description: |
Minutes of hour of day. Must be from 0 to 59.
- !ruby/object:Api::Type::Integer
name: seconds
description: |
Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
- !ruby/object:Api::Type::Integer
name: nanos
description: |
Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
- !ruby/object:Api::Type::NestedObject
name: "timeBasedRetention"
description: |
Time-based Backup retention policy.
conflicts:
- automated_backup_policy.0.quantity_based_retention
properties:
- !ruby/object:Api::Type::String
name: "retentionPeriod"
description: |
The retention period.
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
- !ruby/object:Api::Type::NestedObject
name: "quantityBasedRetention"
conflicts:
- automated_backup_policy.0.time_based_retention
description: |
Quantity-based Backup retention policy to retain recent backups.
properties:
- !ruby/object:Api::Type::Integer
name: "count"
description: |
The number of backups to retain.
- !ruby/object:Api::Type::Boolean
name: "enabled"
description: |
Whether automated automated backups are enabled.
- !ruby/object:Api::Type::NestedObject
name: "backupSource"
output: true
description: "Cluster created from backup."
properties:
- !ruby/object:Api::Type::String
name: "backupName"
description: "The name of the backup resource."
- !ruby/object:Api::Type::NestedObject
name: "migrationSource"
output: true
description: "Cluster created via DMS migration."
properties:
- !ruby/object:Api::Type::String
name: "hostPort"
description: "The host and port of the on-premises instance in host:port format"
- !ruby/object:Api::Type::String
name: "referenceId"
description: "Place holder for the external source identifier(e.g DMS job name) that created the cluster."
- !ruby/object:Api::Type::String
name: "sourceType"
description: "Type of migration source."
38 changes: 38 additions & 0 deletions mmv1/products/alloydb/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2022 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
!ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Cluster: !ruby/object:Overrides::Terraform::ResourceOverride
import_format: ["projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}}", "{{cluster_id}}"]
properties:
initialUser: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: "templates/terraform/custom_flatten/alloydb_cluster_input_user_flatten.go.erb"
ignore_read: true
initialUser.password: !ruby/object:Overrides::Terraform::PropertyOverride
sensitive: true
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "alloydb_cluster_basic"
min_version: beta
primary_resource_id: "default"
vars:
alloydb_cluster_name: "alloydb-cluster"
- !ruby/object:Provider::Terraform::Examples
name: "alloydb_cluster_full"
min_version: beta
primary_resource_id: "full"
vars:
alloydb_cluster_name: "alloydb-cluster-full"
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%# The license inside this block applies to this file.
# Copyright 2020 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} {
melinath marked this conversation as resolved.
Show resolved Hide resolved
return []interface{}{
map[string]interface{}{
"user": d.Get("initial_user.0.user"),
"password": d.Get("initial_user.0.password"),
},
}
}
15 changes: 15 additions & 0 deletions mmv1/templates/terraform/examples/alloydb_cluster_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_alloydb_cluster" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
cluster_id = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
location = "us-central1"
network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"
}

data "google_project" "project" {
provider = google-beta
}

resource "google_compute_network" "default" {
provider = google-beta
name = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
}
49 changes: 49 additions & 0 deletions mmv1/templates/terraform/examples/alloydb_cluster_full.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
resource "google_alloydb_cluster" "<%= ctx[:primary_resource_id] %>" {
melinath marked this conversation as resolved.
Show resolved Hide resolved
provider = google-beta
cluster_id = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
location = "us-central1"
network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"

initial_user {
user = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
password = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
}

automated_backup_policy {
location = "us-central1"
backup_window = "1800s"
enabled = true

weekly_schedule {
days_of_week = ["MONDAY"]

start_times {
hours = 23
minutes = 0
seconds = 0
nanos = 0
}
}

quantity_based_retention {
count = 1
}

labels = {
test = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
}
}

labels = {
test = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
}
}

data "google_project" "project" {
provider = google-beta
}

resource "google_compute_network" "default" {
provider = google-beta
name = "<%= ctx[:vars]['alloydb_cluster_name'] %>"
}