Skip to content

Commit 8d44d7b

Browse files
committed
Fixed based on pr review comments
1 parent 287e403 commit 8d44d7b

5 files changed

+306
-18
lines changed

mmv1/products/memorystore/Instance.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ examples:
7676
'prevent_destroy': 'false'
7777
virtual_fields:
7878
- name: 'desired_psc_auto_connections'
79-
description: "Required. Immutable. User inputs for the auto-created
79+
description: "Immutable. User inputs for the auto-created
8080
PSC connections. "
8181
type: Array
8282
immutable: true
@@ -401,7 +401,7 @@ properties:
401401
- name: 'dnsName'
402402
type: String
403403
description:
404-
"Recommended to create a DNS record with the dnsName per client and point to the PSC endpoint IP address."
404+
"The PSC endpoint IP address"
405405
output: true
406406
- name: 'connectionType'
407407
type: String

mmv1/products/memorystore/InstanceDesiredUserCreatedConnections.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@ async:
4848
base_url: '{{op_id}}'
4949
result:
5050
resource_inside_response: false
51+
examples:
52+
- name: 'memorystore_instance_desired_user_created_connections'
53+
primary_resource_id: 'instance-user-conn'
54+
vars:
55+
instance_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+
instance_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'
5181
parameters:
5282
- name: 'name'
5383
type: String

mmv1/templates/terraform/custom_flatten/memorystore_instance_desired_user_created_connections_desired_endpoints.go.tmpl

+16-16
Original file line numberDiff line numberDiff line change
@@ -53,51 +53,51 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnection(v int
5353
}
5454
transformed := make(map[string]interface{})
5555
transformed["psc_connection_id"] =
56-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(original["pscConnectionId"], d, config)
56+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(original["pscConnectionId"], d, config)
5757
transformed["ip_address"] =
58-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionIpAddress(original["ipAddress"], d, config)
58+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionIpAddress(original["ipAddress"], d, config)
5959
transformed["forwarding_rule"] =
60-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(original["forwardingRule"], d, config)
60+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(original["forwardingRule"], d, config)
6161
transformed["project_id"] =
62-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(original["projectId"], d, config)
62+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(original["projectId"], d, config)
6363
transformed["network"] =
64-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(original["network"], d, config)
64+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(original["network"], d, config)
6565
transformed["service_attachment"] =
66-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(original["serviceAttachment"], d, config)
66+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(original["serviceAttachment"], d, config)
6767
transformed["psc_connection_status"] =
68-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(original["pscConnectionStatus"], d, config)
68+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(original["pscConnectionStatus"], d, config)
6969
transformed["connection_type"] =
70-
flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(original["connectionType"], d, config)
70+
flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(original["connectionType"], d, config)
7171
return []interface{}{transformed}
7272
}
73-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
73+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
7474
return v
7575
}
7676

77-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
77+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
7878
return v
7979
}
8080

81-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
81+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionForwardingRule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
8282
return v
8383
}
8484

85-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
85+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
8686
return v
8787
}
8888

89-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
89+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
9090
return v
9191
}
9292

93-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
93+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionServiceAttachment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
9494
return v
9595
}
9696

97-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
97+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionPscConnectionStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
9898
return v
9999
}
100100

101-
func flatte{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
101+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}ConnectionsPscConnectionConnectionType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
102102
return v
103103
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
resource "google_memorystore_instance_desired_user_created_connections" "{{$.PrimaryResourceId}}" {
2+
name = "{{index $.Vars "instance_name"}}"
3+
region = "us-central1"
4+
desired_user_endpoints {
5+
connections {
6+
psc_connection {
7+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule1_network2.psc_connection_id
8+
ip_address = google_compute_address.ip1_network2.address
9+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule1_network2.id
10+
network = google_compute_network.network2.id
11+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
12+
}
13+
}
14+
connections {
15+
psc_connection {
16+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule2_network2.psc_connection_id
17+
ip_address = google_compute_address.ip2_network2.address
18+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule2_network2.id
19+
network = google_compute_network.network2.id
20+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
21+
}
22+
}
23+
}
24+
}
25+
26+
resource "google_compute_forwarding_rule" "forwarding_rule1_network2" {
27+
name = "{{index $.Vars "forwarding_rule1_network2_name"}}"
28+
region = "us-central1"
29+
ip_address = google_compute_address.ip1_network2.id
30+
load_balancing_scheme = ""
31+
network = google_compute_network.network2.id
32+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
33+
}
34+
35+
resource "google_compute_forwarding_rule" "forwarding_rule2_network2" {
36+
name = "{{index $.Vars "forwarding_rule2_network2_name"}}"
37+
region = "us-central1"
38+
ip_address = google_compute_address.ip2_network2.id
39+
load_balancing_scheme = ""
40+
network = google_compute_network.network2.id
41+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
42+
}
43+
44+
resource "google_compute_address" "ip1_network2" {
45+
name = "{{index $.Vars "ip1_network2_name"}}"
46+
region = "us-central1"
47+
subnetwork = google_compute_subnetwork.subnet_network2.id
48+
address_type = "INTERNAL"
49+
purpose = "GCE_ENDPOINT"
50+
}
51+
52+
resource "google_compute_address" "ip2_network2" {
53+
name = "{{index $.Vars "ip2_network2_name"}}"
54+
region = "us-central1"
55+
subnetwork = google_compute_subnetwork.subnet_network2.id
56+
address_type = "INTERNAL"
57+
purpose = "GCE_ENDPOINT"
58+
}
59+
60+
resource "google_compute_subnetwork" "subnet_network2" {
61+
name = "{{index $.Vars "subnet_network2_name"}}"
62+
ip_cidr_range = "10.0.0.248/29"
63+
region = "us-central1"
64+
network = google_compute_network.network2.id
65+
}
66+
67+
resource "google_compute_network" "network2" {
68+
name = "{{index $.Vars "network2_name"}}"
69+
auto_create_subnetworks = false
70+
}
71+
72+
//valkey instance with endpoints
73+
resource "google_memorystore_instance" "{{$.PrimaryResourceId}}" {
74+
instance_id = "{{index $.Vars "instance_name"}}"
75+
shard_count = 3
76+
desired_psc_auto_connections {
77+
network = google_compute_network.network1.id
78+
project_id = data.google_project.project.project_id
79+
}
80+
location = "us-central1"
81+
deletion_protection_enabled = false
82+
depends_on = [google_network_connectivity_service_connection_policy.default]
83+
84+
}
85+
86+
resource "google_network_connectivity_service_connection_policy" "default" {
87+
name = "{{index $.Vars "policy_name"}}"
88+
location = "us-central1"
89+
service_class = "gcp-memorystore"
90+
description = "my basic service connection policy"
91+
network = google_compute_network.network1.id
92+
psc_config {
93+
subnetworks = [google_compute_subnetwork.subnet_network1.id]
94+
}
95+
}
96+
97+
resource "google_compute_subnetwork" "subnet_network1" {
98+
name = "{{index $.Vars "subnet_network1_name"}}"
99+
ip_cidr_range = "10.0.0.248/29"
100+
region = "us-central1"
101+
network = google_compute_network.network1.id
102+
}
103+
104+
resource "google_compute_network" "network1" {
105+
name = "{{index $.Vars "network1_name"}}"
106+
auto_create_subnetworks = false
107+
}
108+
109+
data "google_project" "project" {
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
resource "google_memorystore_instance_desired_user_created_connections" "{{$.PrimaryResourceId}}" {
2+
name = "{{index $.Vars "instance_name"}}"
3+
region = "us-central1"
4+
desired_user_endpoints {
5+
connections {
6+
psc_connection {
7+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule1_network2.psc_connection_id
8+
ip_address = google_compute_address.ip1_network2.address
9+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule1_network2.id
10+
network = google_compute_network.network2.id
11+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
12+
}
13+
}
14+
connections {
15+
psc_connection {
16+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule2_network2.psc_connection_id
17+
ip_address = google_compute_address.ip2_network2.address
18+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule2_network2.id
19+
network = google_compute_network.network2.id
20+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
21+
}
22+
}
23+
}
24+
desired_user_endpoints {
25+
connections {
26+
psc_connection {
27+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule1_network2.psc_connection_id
28+
ip_address = google_compute_address.ip1_network2.address
29+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule1_network2.id
30+
network = google_compute_network.network2.id
31+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
32+
}
33+
}
34+
connections {
35+
psc_connection {
36+
psc_connection_id = google_compute_forwarding_rule.forwarding_rule2_network2.psc_connection_id
37+
ip_address = google_compute_address.ip2_network2.address
38+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule2_network2.id
39+
network = google_compute_network.network2.id
40+
service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
41+
}
42+
}
43+
}
44+
}
45+
46+
resource "google_compute_forwarding_rule" "forwarding_rule1_network1" {
47+
name = "{{index $.Vars "forwarding_rule1_network1_name"}}"
48+
region = "us-central1"
49+
ip_address = google_compute_address.ip1_network1.id
50+
load_balancing_scheme = ""
51+
network = google_compute_network.network1.id
52+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
53+
}
54+
55+
resource "google_compute_forwarding_rule" "forwarding_rule2_network1" {
56+
name = "{{index $.Vars "forwarding_rule2_network1_name"}}"
57+
region = "us-central1"
58+
ip_address = google_compute_address.ip2_network1.id
59+
load_balancing_scheme = ""
60+
network = google_compute_network.network1.id
61+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
62+
}
63+
64+
resource "google_compute_address" "ip1_network1" {
65+
name = "{{index $.Vars "ip1_network1_name"}}"
66+
region = "us-central1"
67+
subnetwork = google_compute_subnetwork.subnet_network1.id
68+
address_type = "INTERNAL"
69+
purpose = "GCE_ENDPOINT"
70+
}
71+
72+
resource "google_compute_address" "ip2_network1" {
73+
name = "{{index $.Vars "ip2_network1_name"}}"
74+
region = "us-central1"
75+
subnetwork = google_compute_subnetwork.subnet_network1.id
76+
address_type = "INTERNAL"
77+
purpose = "GCE_ENDPOINT"
78+
}
79+
80+
resource "google_compute_subnetwork" "subnet_network1" {
81+
name = "{{index $.Vars "subnet_network1_name"}}"
82+
ip_cidr_range = "10.0.0.248/29"
83+
region = "us-central1"
84+
network = google_compute_network.network1.id
85+
}
86+
87+
resource "google_compute_network" "network1" {
88+
name = "{{index $.Vars "network1_name"}}"
89+
auto_create_subnetworks = false
90+
}
91+
92+
resource "google_compute_forwarding_rule" "forwarding_rule1_network2" {
93+
name = "{{index $.Vars "forwarding_rule1_network2_name"}}"
94+
region = "us-central1"
95+
ip_address = google_compute_address.ip1_network2.id
96+
load_balancing_scheme = ""
97+
network = google_compute_network.network2.id
98+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
99+
}
100+
101+
resource "google_compute_forwarding_rule" "forwarding_rule2_network2" {
102+
name = "{{index $.Vars "forwarding_rule2_network2_name"}}"
103+
region = "us-central1"
104+
ip_address = google_compute_address.ip2_network2.id
105+
load_balancing_scheme = ""
106+
network = google_compute_network.network2.id
107+
target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
108+
}
109+
110+
resource "google_compute_address" "ip1_network2" {
111+
name = "{{index $.Vars "ip1_network2_name"}}"
112+
region = "us-central1"
113+
subnetwork = google_compute_subnetwork.subnet_network2.id
114+
address_type = "INTERNAL"
115+
purpose = "GCE_ENDPOINT"
116+
}
117+
118+
resource "google_compute_address" "ip2_network2" {
119+
name = "{{index $.Vars "ip2_network2_name"}}"
120+
region = "us-central1"
121+
subnetwork = google_compute_subnetwork.subnet_network2.id
122+
address_type = "INTERNAL"
123+
purpose = "GCE_ENDPOINT"
124+
}
125+
126+
//Valkey instance without endpoints
127+
resource "google_memorystore_instance" "{{$.PrimaryResourceId}}" {
128+
instance_id = "{{index $.Vars "instance_name"}}"
129+
shard_count = 3
130+
location = "us-central1"
131+
deletion_protection_enabled = false
132+
}
133+
134+
resource "google_compute_subnetwork" "subnet_network2" {
135+
name = "{{index $.Vars "subnet_network2_name"}}"
136+
ip_cidr_range = "10.0.0.248/29"
137+
region = "us-central1"
138+
network = google_compute_network.network2.id
139+
}
140+
141+
resource "google_compute_network" "network2" {
142+
name = "{{index $.Vars "network2_name"}}"
143+
auto_create_subnetworks = false
144+
}
145+
146+
147+
data "google_project" "project" {
148+
}

0 commit comments

Comments
 (0)