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

Redis cluster terraform support #8567

Merged
merged 19 commits into from
Aug 28, 2023
32 changes: 29 additions & 3 deletions mmv1/products/networkconnectivity/ServiceConnectionPolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ properties:
name: 'pscConfig'
description: |
Configuration used for Private Service Connect connections. Used when Infrastructure is PSC.
properties:
properties:
- !ruby/object:Api::Type::Array
name: 'subnetworks'
required: true
Expand All @@ -125,9 +125,35 @@ properties:
- !ruby/object:Api::Type::Array
name: 'pscConnections'
output: true
item_type: Api::Type::String
description: |
Information about each Private Service Connect connection.
Information about each Private Service Connect connection.\
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::Enum
name: state
description: The state of the PSC connection.
values:
- :STATE_UNSPECIFIED
- :ACTIVE
- :CREATING
- :DELETING
- :FAILED
- !ruby/object:Api::Type::String
name: consumerForwardingRule
description: |
The resource reference of the PSC Forwarding Rule within the consumer VPC
- !ruby/object:Api::Type::String
name: gceOperation
description: xyz
- !ruby/object:Api::Type::String
name: consumerTargetProject
description: xyz
- !ruby/object:Api::Type::String
name: pscConnectionId
description: xyz
- !ruby/object:Api::Type::String
name: consumerAddress
description: xyz
- !ruby/object:Api::Type::String
name: 'infrastructure'
output: true
Expand Down
211 changes: 211 additions & 0 deletions mmv1/products/redis/Cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# Copyright 2023 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::Resource
name: 'Cluster'
description: |
A Google Cloud Redis Cluster instance.
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/memorystore/docs/cluster/'
api: 'https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1alpha1/projects.locations.clusters'
himanikh marked this conversation as resolved.
Show resolved Hide resolved
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 60
update_minutes: 120
delete_minutes: 30
min_version: beta
base_url: 'projects/{{project}}/locations/{{region}}/clusters'
self_link: 'projects/{{project}}/locations/{{region}}/clusters/{{name}}'
create_url: 'projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}'
update_verb: :PATCH
update_mask: true
autogen_async: true
parameters:
- !ruby/object:Api::Type::String
name: name
description: |
Unique name of the resource in this scope including project and location using the form:
projects/{projectId}/locations/{locationId}/clusters/{clusterId}
required: true
immutable: true
url_param_only: true
default_from_api: true
- !ruby/object:Api::Type::String
name: 'region'
required: false
immutable: true
url_param_only: true
description: |
The name of the region of the Redis cluster.
ignore_read: true
default_from_api: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "redis_cluster_ha"
min_version: beta
primary_resource_id: "cluster-ha"
vars:
cluster_name: "ha-cluster"
policy_name: "mypolicy"
subnet_name: "mysubnet"
network_name: "mynetwork"
properties:
- !ruby/object:Api::Type::Time
name: createTime
description: |
The timestamp associated with the cluster creation request. A timestamp in
RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional
digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
output: true
- !ruby/object:Api::Type::Enum
name: state
description: |
The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED
values:
- :CREATING
- :READY
- :UPDATING
- :DELETING
- :SUSPENDED
immutable: true
output: true
- !ruby/object:Api::Type::String
name: uid
description: |
System assigned, unique identifier for the cluster.
output: true
- !ruby/object:Api::Type::Enum
name: authorizationMode
description: |
Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster.
values:
- :AUTH_MODE_UNSPECIFIED
- :AUTH_MODE_IAM_AUTH
- :AUTH_MODE_DISABLED
default_value: :AUTH_MODE_DISABLED
immutable: true
required: false
- !ruby/object:Api::Type::Enum
name: transitEncryptionMode
description: |
Optional. The in-transit encryption for the Redis cluster.
If not provided, encryption is disabled for the cluster.
values:
- :TRANSIT_ENCRYPTION_MODE_UNSPECIFIED
- :TRANSIT_ENCRYPTION_MODE_DISABLED
- :TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION
default_value: :TRANSIT_ENCRYPTION_MODE_DISABLED
immutable: true
required: false
- !ruby/object:Api::Type::Array
name: 'pscConfigs'
description: |
Required. Each PscConfig configures the consumer network where two
network addresses will be designated to the cluster for client access.
Currently, only one PscConfig is supported.
required: true
ignore_read: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'network'
description: |
Required. The consumer network where the network address of
the discovery endpoint will be reserved, in the form of
projects/{network_project_id_or_number}/global/networks/{network_id}.
required: true
- !ruby/object:Api::Type::Array
name: 'discoveryEndpoints'
description: |
Output only. Endpoints created on each given network,
for Redis clients to connect to the cluster.
Currently only one endpoint is supported.
output: true
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'address'
description: |
Output only. Network address of the exposed Redis endpoint used by clients to connect to the service.
- !ruby/object:Api::Type::Integer
name: 'port'
description: |
Output only. The port number of the exposed Redis endpoint.
- !ruby/object:Api::Type::NestedObject
name: 'pscConfig'
description: |
Output only. Customer configuration for where the endpoint
is created and accessed from.
properties:
- !ruby/object:Api::Type::String
name: 'network'
description: |
The consumer network where the network address of the discovery
endpoint will be reserved, in the form of
projects/{network_project_id}/global/networks/{network_id}.
- !ruby/object:Api::Type::Array
name: 'pscConnections'
description: |
Output only. PSC connections for discovery of the cluster topology and accessing the cluster.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'pscConnectionId'
description: |
Output only. The PSC connection id of the forwarding rule connected to the service attachment.
- !ruby/object:Api::Type::String
name: 'address'
description: |
Output only. The IP allocated on the consumer network for the PSC forwarding rule.
- !ruby/object:Api::Type::String
name: 'forwardingRule'
description: |
Output only. The URI of the consumer side forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}.
- !ruby/object:Api::Type::String
name: 'projectId'
description: |
Output only. The consumer projectId where the forwarding rule is created from.
- !ruby/object:Api::Type::String
name: 'network'
description: |
The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}.
output: true
- !ruby/object:Api::Type::NestedObject
name: stateInfo
description: Output only. Additional information about the current state of the cluster.
properties:
- !ruby/object:Api::Type::NestedObject
name: updateInfo
properties:
- !ruby/object:Api::Type::Integer
name: targetShardCount
description: Target number of shards for redis cluster.
- !ruby/object:Api::Type::Integer
name: targetReplicaCount
description: Target number of replica nodes per shard.
output: true
- !ruby/object:Api::Type::Integer
name: replicaCount
description: |
Optional. The number of replica nodes per shard.
required: false
- !ruby/object:Api::Type::Integer
name: sizeGb
description: |
Output only. Redis memory size in GB for the entire cluster.
output: true
- !ruby/object:Api::Type::Integer
himanikh marked this conversation as resolved.
Show resolved Hide resolved
name: shardCount
description: |
Required. Number of shards for the Redis cluster.
required: true
17 changes: 3 additions & 14 deletions mmv1/products/redis/product.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ versions:
scopes:
- https://www.googleapis.com/auth/cloud-platform
async: !ruby/object:Api::OpAsync
# Overrides which API calls return operations. Default: ['create',
# 'update', 'delete']
# actions: ['create', 'update', 'delete']
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::OpAsync::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
41 changes: 41 additions & 0 deletions mmv1/templates/terraform/examples/redis_cluster_ha.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
resource "google_redis_cluster" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
name = "<%= ctx[:vars]['cluster_name'] %>"
shard_count = 3
psc_configs {
network = google_compute_network.producer_net.id
}
region = "us-central1"
replica_count = 1
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
authorization_mode = "AUTH_MODE_DISABLED"
depends_on = [
google_network_connectivity_service_connection_policy.default
]
}

resource "google_network_connectivity_service_connection_policy" "default" {
provider = google-beta
name = "<%= ctx[:vars]['policy_name'] %>"
location = "us-central1"
service_class = "gcp-memorystore-redis"
description = "my basic service connection policy"
network = google_compute_network.producer_net.id
psc_config {
subnetworks = [google_compute_subnetwork.producer_subnet.id]
}
}

resource "google_compute_subnetwork" "producer_subnet" {
provider = google-beta
name = "<%= ctx[:vars]['subnet_name'] %>"
ip_cidr_range = "10.0.0.248/29"
region = "us-central1"
network = google_compute_network.producer_net.id
}

resource "google_compute_network" "producer_net" {
provider = google-beta
name = "<%= ctx[:vars]['network_name'] %>"
auto_create_subnetworks = false
}
Loading
Loading