Skip to content

Commit

Permalink
feat!: Rename project input variable to project_id (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w authored Oct 11, 2024
1 parent 424b40a commit 04cef76
Show file tree
Hide file tree
Showing 21 changed files with 231 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <pre>object({<br> persistence_mode = string<br> rdb_snapshot_period = string<br> })</pre> | `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 |
Expand Down
23 changes: 23 additions & 0 deletions docs/upgrading_to_v12.0.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion examples/basic/memorystore.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module "memorystore" {
version = "~> 11.0"

name = "memorystore"
project = "memorystore"
project_id = "memorystore"
memory_size_gb = "1"
enable_apis = "true"
}
2 changes: 1 addition & 1 deletion examples/memcache/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/redis-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,12 +48,14 @@ spec:
location: examples/redis
- name: redis-cluster
location: examples/redis-cluster
- name: valkey
location: examples/valkey
interfaces:
variables:
- 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
Expand All @@ -69,7 +73,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: tier
Expand Down Expand Up @@ -157,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
Expand Down
2 changes: 1 addition & 1 deletion modules/memcache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
4 changes: 2 additions & 2 deletions modules/memcache/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions modules/memcache/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
version: 11.1.0
actuationTool:
flavor: Terraform
version: ">= 0.13"
version: ">= 1.3"
description: {}
content:
examples:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/memcache/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion modules/redis-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <pre>object({<br> maxmemory-clients = optional(string)<br> maxmemory = optional(string)<br> maxmemory-policy = optional(string)<br> notify-keyspace-events = optional(string)<br> slowlog-log-slower-than = optional(number)<br> maxclients = optional(number)<br> })</pre> | `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 |
Expand Down
4 changes: 2 additions & 2 deletions modules/redis-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion modules/redis-cluster/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/redis-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit 04cef76

Please sign in to comment.