Skip to content

Commit

Permalink
fix(TPG >=4.74)!: remove ignore maintenance_schedule. Added redis clu…
Browse files Browse the repository at this point in the history
…ster sub-module (#195)
  • Loading branch information
imrannayer authored Jan 4, 2024
1 parent 99be0fb commit 10c10ba
Show file tree
Hide file tree
Showing 25 changed files with 596 additions and 76 deletions.
52 changes: 36 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
# [Google Cloud Memorystore Terraform Module](https://registry.terraform.io/modules/terraform-google-modules/memorystore/google/)

A Terraform module for creating a fully functional Google Memorystore (redis) instance.
A Terraform module for creating a fully functional Google Memorystore Redis instance. For Memcache and Redis Cluster see [sub-modules](./modules/)

## Compatibility
This module is meant for use with Terraform 0.13+ and tested using Terraform 1.0+. If you find incompatibilities using Terraform >=0.13, please open an issue.
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.3+. If you find incompatibilities using Terraform >=1.3, please open an issue.
If you haven't
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [v2.0.0](https://registry.terraform.io/modules/terraform-google-modules/-memorystore/google/v2.0.0).

## Version

Current version is 8.0. Upgrade guides:

- [7.X -> 8.0](/docs/upgrading_to_v8.0.md)

## Usage

Check the [examples/](./examples/) directory for more.

```hcl
module "memorystore" {
source = "terraform-google-modules/memorystore/google"
version = "4.0.0"
version = "~> 8.0"
name = "my-memorystore"
project = "my-gcp-project"
name = "memorystore"
project = "memorystore"
memory_size_gb = "1"
enable_apis = "true"
}
```

Expand Down Expand Up @@ -68,16 +76,28 @@ module "memorystore" {

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## File structure
## Requirements

These sections describe requirements for using this module.

### Software

The following dependencies must be available:

- [Terraform][terraform] v1.3+
- [Terraform Provider for GCP][terraform-provider-gcp] plugin v4.74+

### Service Account

Following roles contain permissions to deploy resource.

- Cloud Memorystore Redis Admin: `roles/redis.admin`

### Enable API's
In order to operate with the Service Account you must activate the following API on the project where the Service Account was created:

- Compute Engine API - `redis.googleapis.com`

The project has the following folders and files:
## Contributing

- /: root folder
- /examples: examples for using this module
- /scripts: Scripts for specific tasks on module (see Infrastructure section on this file)
- /test: Folders with files for testing the module (see Testing section on this file)
- /helpers: Optional helper scripts for ease of use
- /main.tf: main file for this module, contains all the resources to create
- /variables.tf: all the variables for the module
- /output.tf: the outputs of the module
- /readme.md: this file
Refer to the [contribution guidelines](./CONTRIBUTING.md) for information on contributing to this module.
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 3600s
timeout: 4200s
steps:
- id: swap-module-refs
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
Expand Down
5 changes: 5 additions & 0 deletions docs/upgrading_to_v8.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upgrading to v8.0.0

The v8.0 release contains backwards-incompatible changes.

This update requires upgrading the minimum provider version to `4.74`.
2 changes: 1 addition & 1 deletion examples/basic/memorystore.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "memorystore" {
source = "terraform-google-modules/memorystore/google"
version = "~> 7.0"
version = "~> 8.0"

name = "memorystore"
project = "memorystore"
Expand Down
24 changes: 0 additions & 24 deletions examples/basic/versions.tf

This file was deleted.

2 changes: 1 addition & 1 deletion examples/memcache/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module "private-service-access" {

module "memcache" {
source = "terraform-google-modules/memorystore/google//modules/memcache"
version = "~> 7.0"
version = "~> 8.0"

name = "example-memcache"
project = var.project_id
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "memstore" {
source = "terraform-google-modules/memorystore/google"
version = "~> 7.0"
version = "~> 8.0"

name = "test-minimal"
project = var.project_id
Expand Down
26 changes: 26 additions & 0 deletions examples/redis-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Redis Test

This test will create a new redis cluster.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| project\_id | Google cloud project id to create redis cluster. | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| authorization\_mode | The redis cluster authorization mode |
| cluster\_id | The redis cluster instance ID |
| cluster\_name | The redis cluster name |
| cluster\_region | The redis cluster region |
| project\_id | The redis cluster Project ID |
| replica\_count | The redis cluster replica count |
| shard\_count | The redis cluster shard count |
| size\_gb | The redis cluster size |
| transit\_encryption\_mode | The redis cluster transit encryption mode |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
31 changes: 31 additions & 0 deletions examples/redis-cluster/iam.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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.
*/

## Enable Service Identity and assign Network Connectivity Service Agent role
## https://cloud.google.com/vpc/docs/configure-service-connection-policies#configure-service-project

resource "google_project_service_identity" "network_connectivity_sa" {
provider = google-beta

project = var.project_id
service = "networkconnectivity.googleapis.com"
}

resource "google_project_iam_member" "network_connectivity_sa" {
project = var.project_id
role = "roles/networkconnectivity.serviceAgent"
member = "serviceAccount:${google_project_service_identity.network_connectivity_sa.email}"
}
37 changes: 37 additions & 0 deletions examples/redis-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.
*/

module "redis_cluster" {
source = "terraform-google-modules/memorystore/google//modules/redis-cluster"
version = "~> 8.0"

name = "test-redis-cluster"
project = var.project_id
region = "us-central1"
network = ["projects/${var.project_id}/global/networks/${local.network_name}"]

service_connection_policies = {
test-net-redis-cluster-scp = {
network_name = local.network_name
network_project = var.project_id
subnet_names = [
"subnet-100",
"subnet-101",
]
}
}
depends_on = [module.test_vpc]
}
45 changes: 45 additions & 0 deletions examples/redis-cluster/network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 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.
*/

locals {
network_name = "test-net-redis-cluster"
}

module "test_vpc" {
source = "terraform-google-modules/network/google"
version = "~> 8.0"
project_id = var.project_id
network_name = local.network_name
mtu = 1460

subnets = [
{
subnet_name = "subnet-100"
subnet_ip = "10.10.100.0/24"
subnet_region = "us-central1"
},
{
subnet_name = "subnet-101"
subnet_ip = "10.10.101.0/24"
subnet_region = "us-central1"
},
{
subnet_name = "subnet-102"
subnet_ip = "10.10.102.0/24"
subnet_region = "us-east1"
},
]
}
60 changes: 60 additions & 0 deletions examples/redis-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* 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.
*/

output "project_id" {
description = "The redis cluster Project ID"
value = var.project_id
}

output "cluster_id" {
description = "The redis cluster instance ID"
value = module.redis_cluster.id
}

output "size_gb" {
description = "The redis cluster size"
value = module.redis_cluster.redis_cluster.size_gb
}

output "cluster_region" {
description = "The redis cluster region"
value = module.redis_cluster.redis_cluster.region
}

output "replica_count" {
description = "The redis cluster replica count"
value = module.redis_cluster.redis_cluster.replica_count
}

output "transit_encryption_mode" {
description = "The redis cluster transit encryption mode"
value = module.redis_cluster.redis_cluster.transit_encryption_mode
}

output "cluster_name" {
description = "The redis cluster name"
value = module.redis_cluster.redis_cluster.name
}

output "shard_count" {
description = "The redis cluster shard count"
value = module.redis_cluster.redis_cluster.shard_count
}

output "authorization_mode" {
description = "The redis cluster authorization mode"
value = module.redis_cluster.redis_cluster.authorization_mode
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* 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.
Expand All @@ -14,6 +14,7 @@
* limitations under the License.
*/

terraform {
required_version = ">= 0.12"
variable "project_id" {
description = "Google cloud project id to create redis cluster."
type = string
}
2 changes: 1 addition & 1 deletion examples/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "memstore" {
source = "terraform-google-modules/memorystore/google"
version = "~> 7.0"
version = "~> 8.0"

name = "test-redis"

Expand Down
19 changes: 0 additions & 19 deletions examples/redis/versions.tf

This file was deleted.

Loading

0 comments on commit 10c10ba

Please sign in to comment.