Skip to content

Commit 7440843

Browse files
committed
First commit
1 parent 94029cc commit 7440843

6 files changed

+814
-1
lines changed

mmv1/products/memorystore/Instance.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
name: 'Instance'
1616
description: A Google Cloud Memorystore instance.
1717
docs:
18+
references:
19+
guides:
20+
'Official Documentation': https://cloud.google.com/memorystore/docs/valkey/create-instances
21+
api: 'https://cloud.google.com/memorystore/docs/valkey/reference/rest/v1/projects.locations.instances'
1822
id_format: 'projects/{{project}}/locations/{{location}}/instances/{{instance_id}}'
1923
base_url: 'projects/{{project}}/locations/{{location}}/instances'
2024
self_link: 'projects/{{project}}/locations/{{location}}/instances/{{instance_id}}'
@@ -155,6 +159,16 @@ properties:
155159
"Output only. Target number of replica nodes per shard for the
156160
instance. "
157161
output: true
162+
- name: 'targetEngineVersion'
163+
type: String
164+
description:
165+
"Output only. Target engine version for the instance."
166+
output: true
167+
- name: 'targetNodeType'
168+
type: String
169+
description:
170+
"Output only. Target node type for the instance."
171+
output: true
158172
- name: 'uid'
159173
type: String
160174
description: "Output only. System assigned, unique identifier for the instance. "
@@ -372,6 +386,29 @@ properties:
372386
enum_values:
373387
- 'CLUSTER'
374388
- 'CLUSTER_DISABLED'
389+
- name: 'pscAttachmentDetails'
390+
type: Array
391+
description:
392+
"Configuration of a service attachment of the cluster, for creating PSC connections."
393+
output: true
394+
item_type:
395+
type: NestedObject
396+
properties:
397+
- name: 'serviceAttachment'
398+
type: String
399+
description:
400+
"Service attachment URI which your self-created PscConnection should use as target."
401+
output: true
402+
- name: 'dnsName'
403+
type: String
404+
description:
405+
"Recommended to create a DNS record with the dnsName per client and point to the PSC endpoint IP address."
406+
output: true
407+
- name: 'connectionType'
408+
type: String
409+
description:
410+
"Service attachment URI which your self-created PscConnection should use as target."
411+
output: true
375412
- name: 'pscAutoConnections'
376413
type: Array
377414
description:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'InstanceDesiredUserCreatedConnections'
16+
api_resource_type_kind: Cluster
17+
description: |
18+
Manages user created connections for Memorystore instance
19+
docs:
20+
note: |
21+
Please ensure your connections meet the requirements outlined at
22+
https://cloud.devsite.corp.google.com/memorystore/docs/valkey/about-multiple-vpc-networking#application_connection_requirements.
23+
If you remove a connections item from the resource, the corresponding forwarding rule will no longer be functioning.
24+
If the corresponding forwarding rule is represented in your terraform configuration it is recommended to delete that
25+
`google_compute_forwarding_rule` resource at the same time.
26+
references:
27+
guides:
28+
api: 'https://cloud.google.com/memorystore/docs/valkey/reference/rest/v1/projects.locations.instances'
29+
id_format: 'projects/{{project}}/locations/{{region}}/instances/{{name}}'
30+
base_url: 'projects/{{project}}/locations/{{region}}/instances'
31+
self_link: 'projects/{{project}}/locations/{{region}}/instances/{{name}}'
32+
create_url: 'projects/{{project}}/locations/{{region}}/instances/{{name}}?updateMask=endpoints'
33+
create_verb: PATCH
34+
update_verb: 'PATCH'
35+
update_url: 'projects/{{project}}/locations/{{region}}/instances/{{name}}?updateMask=endpoints'
36+
update_mask: true
37+
custom_code:
38+
custom_delete: 'templates/terraform/custom_delete/memorystore_instance_desired_user_created_connections.go.tmpl'
39+
timeouts:
40+
insert_minutes: 60
41+
update_minutes: 120
42+
delete_minutes: 30
43+
autogen_async: true
44+
async:
45+
actions: ['create', 'delete', 'update']
46+
type: 'OpAsync'
47+
operation:
48+
base_url: '{{op_id}}'
49+
result:
50+
resource_inside_response: false
51+
examples:
52+
- name: 'memorystore_instance_desired_user_created_connections'
53+
primary_resource_id: 'instance-user-conn'
54+
vars:
55+
cluster_name: 'instance-user-conn'
56+
network1_name: 'net1'
57+
subnet_network1_name: 'subnet-net1'
58+
ip1_network1_name: 'ip1-net1'
59+
ip2_network1_name: 'ip2-net1'
60+
forwarding_rule1_network1_name: 'fwd1-net1'
61+
forwarding_rule2_network1_name: 'fwd2-net1'
62+
network2_name: 'network2'
63+
subnet_network2_name: 'subnet-net2'
64+
ip1_network2_name: 'ip1-net2'
65+
ip2_network2_name: 'ip2-net2'
66+
forwarding_rule1_network2_name: 'fwd1-net2'
67+
forwarding_rule2_network2_name: 'fwd2-net2'
68+
- name: 'memorystore_instance_desired_user_and_auto_created_connections'
69+
primary_resource_id: 'instance-user-auto-conn'
70+
vars:
71+
cluster_name: 'instance-user-auto-conn'
72+
network1_name: 'net1'
73+
subnet_network1_name: 'subnet-net1'
74+
policy_name: 'scpolicy'
75+
network2_name: 'network2'
76+
subnet_network2_name: 'subnet-net2'
77+
ip1_network2_name: 'ip1-net2'
78+
ip2_network2_name: 'ip2-net2'
79+
forwarding_rule1_network2_name: 'fwd1-net2'
80+
forwarding_rule2_network2_name: 'fwd2-net2'
81+
parameters:
82+
- name: 'name'
83+
type: String
84+
description: |
85+
The name of the Memorystore instance these endpoints should be added to.
86+
required: true
87+
url_param_only: true
88+
- name: 'region'
89+
type: String
90+
description: |
91+
The name of the region of the Memorystore instance these endpoints should be added to.
92+
url_param_only: true
93+
required: true
94+
properties:
95+
- name: 'instanceEndpoints'
96+
type: Array
97+
description: "A list of instance endpoints"
98+
item_type:
99+
type: NestedObject
100+
description: |
101+
Instance Endpoint consists of PSC connections that are created
102+
as a group in each VPC network for accessing the Instance. In each group,
103+
there shall be one connection for each service attachment in the Instance.
104+
properties:
105+
- name: connections
106+
type: Array
107+
item_type:
108+
type: NestedObject
109+
name: 'connections'
110+
properties:
111+
- name: 'pscConnection'
112+
type: NestedObject
113+
description: |
114+
Detailed information of a PSC connection that is created by the customer
115+
who owns the cluster.
116+
properties:
117+
- name: 'pscConnectionId'
118+
type: String
119+
description:
120+
"The PSC connection id of the forwarding rule connected
121+
to the\nservice attachment."
122+
required: true
123+
- name: 'address'
124+
type: String
125+
description:
126+
"The IP allocated on the consumer network for the
127+
PSC forwarding rule. "
128+
required: true
129+
- name: 'forwardingRule'
130+
type: String
131+
description: "The URI of the consumer side forwarding rule.\nFormat:\nprojects/{project}/regions/{region}/forwardingRules/{forwarding_rule} "
132+
required: true
133+
- name: 'projectId'
134+
type: String
135+
description:
136+
"The consumer project_id where the forwarding rule is
137+
created from. "
138+
default_from_api: true
139+
- name: 'network'
140+
type: String
141+
description:
142+
"The consumer network where the IP address resides, in
143+
the form of\nprojects/{project_id}/global/networks/{network_id}. "
144+
required: true
145+
- name: 'serviceAttachment'
146+
type: String
147+
description:
148+
"The service attachment which is the target of the PSC connection, in the form of
149+
projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}."
150+
required: true
151+
- name: 'pscConnectionStatus'
152+
type: Enum
153+
description:
154+
"Output Only. The status of the PSC connection: whether a connection exists and ACTIVE or it no longer exists.
155+
\n Possible values:\n ACTIVE \n NOT_FOUND"
156+
output: true
157+
- name: 'connectionType'
158+
type: Enum
159+
description:
160+
"Output Only. Type of a PSC Connection.
161+
\n Possible values:\n CONNECTION_TYPE_DISCOVERY \n CONNECTION_TYPE_PRIMARY \n CONNECTION_TYPE_READER"
162+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
billingProject := ""
2+
3+
project, err := tpgresource.GetProject(d, config)
4+
if err != nil {
5+
return fmt.Errorf("Error fetching project for InstanceDesiredUserCreatedConnections: %s", err)
6+
}
7+
billingProject = project
8+
9+
obj := make(map[string]interface{})
10+
// not setting instanceEndpoints in obj
11+
12+
13+
url, err := tpgresource.ReplaceVars(d, config, "{{"{{"}}MemorystoreBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/locations/{{"{{"}}region{{"}}"}}/instances/{{"{{"}}name{{"}}"}}")
14+
if err != nil {
15+
return err
16+
}
17+
18+
log.Printf("[DEBUG] Updating InstanceDesiredUserCreatedConnections %q: %#v", d.Id(), obj)
19+
headers := make(http.Header)
20+
21+
updateMask := []string{}
22+
updateMask = append(updateMask, "instanceEndpoints")
23+
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
24+
// won't set it
25+
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
26+
if err != nil {
27+
return err
28+
}
29+
30+
// err == nil indicates that the billing_project value was found
31+
if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
32+
billingProject = bp
33+
}
34+
35+
obj["async_instance_endpoints_deletion_enabled"] = true
36+
37+
// if updateMask is empty we are not updating anything so skip the post
38+
if len(updateMask) > 0 {
39+
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
40+
Config: config,
41+
Method: "PATCH",
42+
Project: billingProject,
43+
RawURL: url,
44+
UserAgent: userAgent,
45+
Body: obj,
46+
Timeout: d.Timeout(schema.TimeoutUpdate),
47+
Headers: headers,
48+
})
49+
50+
if err != nil {
51+
return fmt.Errorf("Error updating InstanceDesiredUserCreatedConnections %q: %s", d.Id(), err)
52+
} else {
53+
log.Printf("[DEBUG] Finished updating InstanceDesiredUserCreatedConnections %q: %#v", d.Id(), res)
54+
}
55+
56+
err = MemorystoreOperationWaitTime(
57+
config, res, project, "Updating InstanceDesiredUserCreatedConnections", userAgent,
58+
d.Timeout(schema.TimeoutUpdate))
59+
60+
if err != nil {
61+
return err
62+
}
63+
}
64+
return resourceMemorystoreInstanceDesiredUserCreatedConnectionsRead(d, meta)

0 commit comments

Comments
 (0)