From 4e677e70f6be24efdff76f78bae0a089d0b2f817 Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Tue, 8 Oct 2024 13:56:26 +0000 Subject: [PATCH 1/4] Rename project to project_id --- README.md | 2 +- docs/upgrading_to_v12.0.md | 23 +++++++++++++++++++++++ examples/basic/memorystore.tf | 2 +- examples/memcache/main.tf | 2 +- examples/minimal/main.tf | 2 +- examples/redis-cluster/main.tf | 2 +- examples/redis/main.tf | 2 +- main.tf | 4 ++-- metadata.display.yaml | 6 ++++++ metadata.yaml | 2 +- modules/memcache/README.md | 2 +- modules/memcache/main.tf | 4 ++-- modules/memcache/variables.tf | 2 +- modules/redis-cluster/README.md | 2 +- modules/redis-cluster/main.tf | 4 ++-- modules/redis-cluster/variables.tf | 2 +- variables.tf | 2 +- 17 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 docs/upgrading_to_v12.0.md diff --git a/README.md b/README.md index 832759f9..742b158b 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ module "memorystore" { | memory\_size\_gb | Redis memory size in GiB. Defaulted to 1 GiB | `number` | `1` | no | | name | The ID of the instance or a fully qualified identifier for the instance. | `string` | n/a | yes | | persistence\_config | The Redis persistence configuration parameters. https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#persistenceconfig |
object({
persistence_mode = string
rdb_snapshot_period = string
})
| `null` | no | -| project | The ID of the project in which the resource belongs to. | `string` | n/a | yes | +| project\_id | The ID of the project in which the resource belongs to. | `string` | n/a | yes | | read\_replicas\_mode | Read replicas mode. https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#readreplicasmode | `string` | `"READ_REPLICAS_DISABLED"` | no | | redis\_configs | The Redis configuration parameters. See [more details](https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#Instance.FIELDS.redis_configs) | `map(any)` | `{}` | no | | redis\_version | The version of Redis software. | `string` | `null` | no | diff --git a/docs/upgrading_to_v12.0.md b/docs/upgrading_to_v12.0.md new file mode 100644 index 00000000..9f56e616 --- /dev/null +++ b/docs/upgrading_to_v12.0.md @@ -0,0 +1,23 @@ +# Upgrading to v12.0 + +The v12.0 release contains backwards-incompatible changes. + +## Use `project_id` instead of `project` + +This release renames `project` to `project_id`. The required input variable `project_id` will be used to configure the project for the resource creation. + + +```diff +module "memorystore" { + source = "terraform-google-modules/memorystore/google" + version = "~> 11.0" + + name = "memorystore" +- project = "memorystore" ++ project_id = "memorystore" + memory_size_gb = "1" + enable_apis = "true" +} +``` + +To be backward compatible, user needs to set `project_id` instead of `project` input variable. diff --git a/examples/basic/memorystore.tf b/examples/basic/memorystore.tf index 838994a1..3a99c1fd 100644 --- a/examples/basic/memorystore.tf +++ b/examples/basic/memorystore.tf @@ -19,7 +19,7 @@ module "memorystore" { version = "~> 11.0" name = "memorystore" - project = "memorystore" + project_id = "memorystore" memory_size_gb = "1" enable_apis = "true" } diff --git a/examples/memcache/main.tf b/examples/memcache/main.tf index 559404ee..5b9d983c 100644 --- a/examples/memcache/main.tf +++ b/examples/memcache/main.tf @@ -29,7 +29,7 @@ module "memcache" { version = "~> 11.0" name = "example-memcache" - project = var.project_id + project_id = var.project_id memory_size_mb = "1024" enable_apis = true cpu_count = "1" diff --git a/examples/minimal/main.tf b/examples/minimal/main.tf index 3dba3202..61641216 100644 --- a/examples/minimal/main.tf +++ b/examples/minimal/main.tf @@ -19,7 +19,7 @@ module "memstore" { version = "~> 11.0" name = "test-minimal" - project = var.project_id + project_id = var.project_id region = "us-east1" location_id = "us-east1-b" enable_apis = true diff --git a/examples/redis-cluster/main.tf b/examples/redis-cluster/main.tf index 1d1a74de..effd0256 100644 --- a/examples/redis-cluster/main.tf +++ b/examples/redis-cluster/main.tf @@ -38,7 +38,7 @@ module "redis_cluster" { version = "~> 11.0" name = "test-redis-cluster" - project = var.project_id + project_id = var.project_id region = "us-central1" network = ["projects/${var.project_id}/global/networks/${local.network_name}"] node_type = "REDIS_STANDARD_SMALL" diff --git a/examples/redis/main.tf b/examples/redis/main.tf index ad4c11bd..f818fb53 100644 --- a/examples/redis/main.tf +++ b/examples/redis/main.tf @@ -20,7 +20,7 @@ module "memstore" { name = "test-redis" - project = var.project_id + project_id = var.project_id region = "us-east1" location_id = "us-east1-b" alternative_location_id = "us-east1-d" diff --git a/main.tf b/main.tf index 0de71ab8..5a1999ef 100644 --- a/main.tf +++ b/main.tf @@ -17,7 +17,7 @@ resource "google_redis_instance" "default" { depends_on = [module.enable_apis] - project = var.project + project = var.project_id name = var.name tier = var.tier replica_count = var.tier == "STANDARD_HA" ? var.replica_count : null @@ -72,7 +72,7 @@ module "enable_apis" { source = "terraform-google-modules/project-factory/google//modules/project_services" version = "~> 17.0" - project_id = var.project + project_id = var.project_id enable_apis = var.enable_apis disable_services_on_destroy = false disable_dependent_services = false diff --git a/metadata.display.yaml b/metadata.display.yaml index 5e7927c0..199da21e 100644 --- a/metadata.display.yaml +++ b/metadata.display.yaml @@ -96,3 +96,9 @@ spec: transit_encryption_mode: name: transit_encryption_mode title: Transit Encryption Mode + runtime: + outputs: + host: + visibility: VISIBILITY_ROOT + port: + visibility: VISIBILITY_ROOT diff --git a/metadata.yaml b/metadata.yaml index b630e7e1..777c555d 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -61,7 +61,7 @@ spec: connections: - source: source: github.com/terraform-google-modules/terraform-google-network//modules/vpc - version: v9.1.0 + version: ">= 9.1.0" spec: outputExpr: network_name - name: connect_mode diff --git a/modules/memcache/README.md b/modules/memcache/README.md index 19cde4e6..2d21ad9c 100644 --- a/modules/memcache/README.md +++ b/modules/memcache/README.md @@ -19,7 +19,7 @@ A Terraform module for creating a fully functional Google Memorystore (memcache) | name | The ID of the instance or a fully qualified identifier for the instance. | `string` | n/a | yes | | node\_count | Number of nodes in the memcache instance. | `number` | `1` | no | | params | Parameters for the memcache process | `map(string)` | `null` | no | -| project | The ID of the project in which the resource belongs to. | `string` | n/a | yes | +| project\_id | The ID of the project in which the resource belongs to. | `string` | n/a | yes | | region | The GCP region to use. | `string` | n/a | yes | | zones | Zones where memcache nodes should be provisioned. If not provided, all zones will be used. | `list(string)` | `null` | no | diff --git a/modules/memcache/main.tf b/modules/memcache/main.tf index 990a2eeb..4fff65ff 100644 --- a/modules/memcache/main.tf +++ b/modules/memcache/main.tf @@ -17,7 +17,7 @@ resource "google_memcache_instance" "self" { depends_on = [module.enable_apis] provider = google-beta - project = var.project + project = var.project_id zones = var.zones name = var.name region = var.region @@ -62,7 +62,7 @@ module "enable_apis" { source = "terraform-google-modules/project-factory/google//modules/project_services" version = "~> 17.0" - project_id = var.project + project_id = var.project_id enable_apis = var.enable_apis disable_services_on_destroy = false diff --git a/modules/memcache/variables.tf b/modules/memcache/variables.tf index 8c47f934..064e504d 100644 --- a/modules/memcache/variables.tf +++ b/modules/memcache/variables.tf @@ -19,7 +19,7 @@ variable "region" { type = string } -variable "project" { +variable "project_id" { description = "The ID of the project in which the resource belongs to." type = string } diff --git a/modules/redis-cluster/README.md b/modules/redis-cluster/README.md index 9a741fc1..ad6bd469 100644 --- a/modules/redis-cluster/README.md +++ b/modules/redis-cluster/README.md @@ -36,7 +36,7 @@ module "redis_cluster" { | name | The ID of the instance or a fully qualified identifier for the instance. must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number | `string` | n/a | yes | | network | List of 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}. Currently, only one item is supported | `list(string)` | n/a | yes | | node\_type | The nodeType for the Redis cluster. If not provided, REDIS\_HIGHMEM\_MEDIUM will be used as default Possible values are: REDIS\_SHARED\_CORE\_NANO, REDIS\_HIGHMEM\_MEDIUM, REDIS\_HIGHMEM\_XLARGE, REDIS\_STANDARD\_SMALL. | `string` | `null` | no | -| project | The ID of the project in which the resource belongs to. | `string` | n/a | yes | +| project\_id | The ID of the project in which the resource belongs to. | `string` | n/a | yes | | redis\_configs | Configure Redis Cluster behavior using a subset of native Redis configuration parameters |
object({
maxmemory-clients = optional(string)
maxmemory = optional(string)
maxmemory-policy = optional(string)
notify-keyspace-events = optional(string)
slowlog-log-slower-than = optional(number)
maxclients = optional(number)
})
| `null` | no | | region | The name of the region of the Redis cluster | `string` | n/a | yes | | replica\_count | The number of replica nodes per shard. Each shard can have 0, 1, or 2 replica nodes. Replicas provide high availability and additional read throughput, and are evenly distributed across zones | `number` | `0` | no | diff --git a/modules/redis-cluster/main.tf b/modules/redis-cluster/main.tf index 35defff6..68be7a4d 100644 --- a/modules/redis-cluster/main.tf +++ b/modules/redis-cluster/main.tf @@ -15,7 +15,7 @@ */ resource "google_redis_cluster" "redis_cluster" { - project = var.project + project = var.project_id name = var.name shard_count = var.shard_count region = var.region @@ -68,7 +68,7 @@ module "enable_apis" { source = "terraform-google-modules/project-factory/google//modules/project_services" version = "~> 17.0" - project_id = var.project + project_id = var.project_id enable_apis = var.enable_apis disable_services_on_destroy = false diff --git a/modules/redis-cluster/variables.tf b/modules/redis-cluster/variables.tf index 8240941c..7bcfef02 100644 --- a/modules/redis-cluster/variables.tf +++ b/modules/redis-cluster/variables.tf @@ -19,7 +19,7 @@ variable "name" { type = string } -variable "project" { +variable "project_id" { description = "The ID of the project in which the resource belongs to." type = string } diff --git a/variables.tf b/variables.tf index f06c242c..2814f3fe 100644 --- a/variables.tf +++ b/variables.tf @@ -20,7 +20,7 @@ variable "region" { default = null } -variable "project" { +variable "project_id" { description = "The ID of the project in which the resource belongs to." type = string } From e4a560c3e3848edf2a14f968a958ba889d6a8ea5 Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Tue, 8 Oct 2024 14:05:26 +0000 Subject: [PATCH 2/4] Update metadata for module and submodules --- metadata.yaml | 8 +- modules/memcache/metadata.yaml | 6 +- modules/redis-cluster/metadata.yaml | 8 +- modules/valkey/metadata.yaml | 166 ++++++++++++++++++++++++++++ 4 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 modules/valkey/metadata.yaml diff --git a/metadata.yaml b/metadata.yaml index 777c555d..d02252c5 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -27,7 +27,7 @@ spec: version: 11.0.1 actuationTool: flavor: Terraform - version: ">= 0.13" + version: ">= 1.3" description: {} content: subBlueprints: @@ -35,6 +35,8 @@ spec: location: modules/memcache - name: redis-cluster location: modules/redis-cluster + - name: valkey + location: modules/valkey examples: - name: basic location: examples/basic @@ -46,6 +48,8 @@ spec: location: examples/redis - name: redis-cluster location: examples/redis-cluster + - name: valkey + location: examples/valkey interfaces: variables: - name: alternative_location_id @@ -110,7 +114,7 @@ spec: persistence_mode = string rdb_snapshot_period = string }) - - name: project + - name: project_id description: The ID of the project in which the resource belongs to. varType: string required: true diff --git a/modules/memcache/metadata.yaml b/modules/memcache/metadata.yaml index 720fdb2c..682b6932 100644 --- a/modules/memcache/metadata.yaml +++ b/modules/memcache/metadata.yaml @@ -28,7 +28,7 @@ spec: version: 11.0.1 actuationTool: flavor: Terraform - version: ">= 0.13" + version: ">= 1.3" description: {} content: examples: @@ -42,6 +42,8 @@ spec: location: examples/redis - name: redis-cluster location: examples/redis-cluster + - name: valkey + location: examples/valkey interfaces: variables: - name: authorized_network @@ -93,7 +95,7 @@ spec: - name: params description: Parameters for the memcache process varType: map(string) - - name: project + - name: project_id description: The ID of the project in which the resource belongs to. varType: string required: true diff --git a/modules/redis-cluster/metadata.yaml b/modules/redis-cluster/metadata.yaml index 1f71494f..0ade74eb 100644 --- a/modules/redis-cluster/metadata.yaml +++ b/modules/redis-cluster/metadata.yaml @@ -42,12 +42,18 @@ spec: location: examples/redis - name: redis-cluster location: examples/redis-cluster + - name: valkey + location: examples/valkey interfaces: variables: - name: authorization_mode description: "The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. Default value is AUTH_MODE_DISABLED. Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED" varType: string defaultValue: AUTH_MODE_DISABLED + - name: deletion_protection_enabled + description: " Indicates if the cluster is deletion protected or not. If the value if set to true, any delete cluster operation will fail. Default value is true" + varType: bool + defaultValue: true - name: enable_apis description: Flag for enabling memcache.googleapis.com in your project varType: bool @@ -63,7 +69,7 @@ spec: - name: node_type description: "The nodeType for the Redis cluster. If not provided, REDIS_HIGHMEM_MEDIUM will be used as default Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL." varType: string - - name: project + - name: project_id description: The ID of the project in which the resource belongs to. varType: string required: true diff --git a/modules/valkey/metadata.yaml b/modules/valkey/metadata.yaml new file mode 100644 index 00000000..7332be65 --- /dev/null +++ b/modules/valkey/metadata.yaml @@ -0,0 +1,166 @@ +# Copyright 2024 Google LLC +# +# 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. + +apiVersion: blueprints.cloud.google.com/v1alpha1 +kind: BlueprintMetadata +metadata: + name: terraform-google-memorystore-valkey + annotations: + config.kubernetes.io/local-config: "true" +spec: + info: + title: Memorystore Valkey Terraform Module + source: + repo: https://github.com/terraform-google-modules/terraform-google-memorystore.git + sourceType: git + dir: /modules/valkey + version: 11.0.1 + actuationTool: + flavor: Terraform + version: ">= 1.3" + description: {} + content: + examples: + - name: basic + location: examples/basic + - name: memcache + location: examples/memcache + - name: minimal + location: examples/minimal + - name: redis + location: examples/redis + - name: redis-cluster + location: examples/redis-cluster + - name: valkey + location: examples/valkey + interfaces: + variables: + - name: authorization_mode + description: "The Immutable. Authorization mode of the instance. Possible values: AUTH_DISABLED IAM_AUTH" + varType: string + defaultValue: AUTH_DISABLED + - name: deletion_protection_enabled + description: If set to true deletion of the instance will fail + varType: bool + defaultValue: true + - name: enable_apis + description: Flag for enabling memcache.googleapis.com in your project + varType: bool + defaultValue: false + - name: engine_configs + description: User-provided engine configurations for the instance + varType: |- + object({ + maxmemory = optional(string) + maxmemory-clients = optional(string) + maxmemory-policy = optional(string) + notify-keyspace-events = optional(string) + slowlog-log-slower-than = optional(number) + maxclients = optional(number) + }) + - name: engine_version + description: Immutable. Engine version of the instance + varType: string + defaultValue: VALKEY_8_0 + - name: instance_id + description: The ID to use for the instance, which will become the final component of the instance's resource name. Must be 4-63 characters in length with lowercase letters, digits, and hyphens. Must not end with a hyphen. Must be unique within a location + varType: string + required: true + - name: labels + description: The resource labels to represent user provided metadata. + varType: map(string) + defaultValue: {} + - name: location + description: The region where valkey cluster will be created + varType: string + required: true + - name: network + description: Name of the consumer network where the network address of the discovery endpoint will be reserved + varType: string + required: true + - name: network_project + description: project ID of the consumer network where the network address of the discovery endpoint will be reserved. Required for Shared VPC host + varType: string + - name: node_type + description: "The nodeType for the valkey cluster. Possible values are: SHARED_CORE_NANO, HIGHMEM_MEDIUM, HIGHMEM_XLARGE, STANDARD_SMALL" + varType: string + - name: persistence_config + description: User-provided persistence configurations for the instance + varType: |- + object({ + mode = optional(string) + rdb_config = optional(object({ + rdb_snapshot_period = optional(string) + rdb_snapshot_start_time = optional(string) + }), null) + aof_config = optional(object({ + append_fsync = string + }), null) + }) + defaultValue: {} + - name: project_id + description: The ID of the project in which the resource belongs to. + varType: string + required: true + - name: replica_count + description: Number of replica nodes per shard. If omitted the default is 0 replicas + varType: number + defaultValue: 0 + - name: service_connection_policies + description: The Service Connection Policies to create. Required to create service connection policy. Not needed if service connection policy already exist + varType: |- + map(object({ + subnet_names = list(string) + description = optional(string) + limit = optional(number) + labels = optional(map(string), {}) + })) + defaultValue: {} + - name: shard_count + description: Number of shards for the instance + varType: number + defaultValue: 3 + - name: transit_encryption_mode + description: "Immutable. In-transit encryption mode of the instance. Possible values: TRANSIT_ENCRYPTION_DISABLED SERVER_AUTHENTICATION" + varType: string + defaultValue: TRANSIT_ENCRYPTION_DISABLED + - name: zone_distribution_config_mode + description: "The mode for zone distribution for Memorystore valkey cluster (Immutable). If not provided, MULTI_ZONE will be used as default value. Possible values are: MULTI_ZONE, SINGLE_ZONE" + varType: string + defaultValue: MULTI_ZONE + - name: zone_distribution_config_zone + description: The zone for single zone Memorystore valkey cluster (Immutable) + varType: string + outputs: + - name: discovery_endpoints + description: Endpoints created on each given network, for valkey clients to connect to the cluster. Currently only one endpoint is supported + - name: id + description: The valkey cluster instance ID + - name: psc_connections + description: PSC connections for discovery of the cluster topology and accessing the cluster + - name: valkey_cluster + description: The valkey cluster created + requirements: + roles: + - level: Project + roles: + - roles/owner + services: + - cloudresourcemanager.googleapis.com + - serviceusage.googleapis.com + - redis.googleapis.com + - memcache.googleapis.com + - serviceconsumermanagement.googleapis.com + - networkconnectivity.googleapis.com + - compute.googleapis.com From c388603d10d527badd55c2c9b15b608d062aec03 Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Thu, 10 Oct 2024 07:11:29 +0000 Subject: [PATCH 3/4] Update output value and type for env_vars --- metadata.yaml | 2 +- outputs.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.yaml b/metadata.yaml index dda45b9d..99babbff 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -161,7 +161,7 @@ spec: type: - object - REDIS_HOST: string - REDIS_PORT: number + REDIS_PORT: string - name: host description: The IP address of the instance. type: string diff --git a/outputs.tf b/outputs.tf index f1d26271..e3724257 100644 --- a/outputs.tf +++ b/outputs.tf @@ -65,6 +65,6 @@ output "env_vars" { description = "Exported environment variables" value = { "REDIS_HOST" : google_redis_instance.default.host, - "REDIS_PORT" : google_redis_instance.default.port + "REDIS_PORT" : tostring(google_redis_instance.default.port) } } From 789dfecc339ba90eec14e3d56a52fb0a199f2ddc Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Thu, 10 Oct 2024 07:29:35 +0000 Subject: [PATCH 4/4] Address comments --- metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.yaml b/metadata.yaml index 99babbff..50c3b281 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -55,7 +55,7 @@ spec: - name: region description: The GCP region to use. varType: string - - name: project + - name: project_id description: The ID of the project in which the resource belongs to. varType: string required: true