Skip to content

Commit d3b9c3f

Browse files
authored
Merge branch 'master' into master
2 parents bd2889d + 9c3c3f3 commit d3b9c3f

File tree

17 files changed

+812
-19
lines changed

17 files changed

+812
-19
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Google Cloud Memorystore Terraform Module
22
[terraform registry](https://registry.terraform.io/modules/terraform-google-modules/memorystore/google/)
33

4-
A Terraform module for creating a fully functional Google Memorystore Redis instance. For Memcache and Redis Cluster see [sub-modules](./modules/)
4+
A Terraform module for creating a fully functional Google Memorystore Redis instance. For other memory store engine use [sub-modules](https://github.com/terraform-google-modules/terraform-google-memorystore/tree/master/modules).
5+
6+
- Memcache [sub-modules](https://github.com/terraform-google-modules/terraform-google-memorystore/tree/master/modules/memcache)
7+
- Redis Cluster [sub-modules](https://github.com/terraform-google-modules/terraform-google-memorystore/tree/master/modules/redis-cluster)
8+
- Valkey [sub-modules](https://github.com/terraform-google-modules/terraform-google-memorystore/tree/master/modules/valkey)
59

610
## Compatibility
711
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.
@@ -19,7 +23,7 @@ Current version is 11.0. Upgrade guides:
1923

2024
## Usage
2125

22-
Check the [examples/](./examples/) directory for more.
26+
Check the [examples/](https://github.com/terraform-google-modules/terraform-google-memorystore/tree/master/examples) directory for more.
2327

2428
```hcl
2529
module "memorystore" {

build/int.cloudbuild.yaml

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
timeout: 4200s
15+
timeout: 5400s
1616
steps:
1717
- id: swap-module-refs
1818
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
@@ -27,15 +27,61 @@ steps:
2727
- id: create
2828
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
2929
args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose --test-dir test/integration']
30-
- id: converge
30+
- id: converge-TestMinimalModule
31+
waitFor:
32+
- create
3133
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
32-
args: ['/bin/bash', '-c', 'cft test run all --stage apply --verbose --test-dir test/integration']
33-
- id: verify
34+
args: ['/bin/bash', '-c', 'cft test run TestMinimalModule --stage apply --verbose --test-dir test/integration']
35+
- id: verify-TestMinimalModule
3436
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
35-
args: ['/bin/bash', '-c', 'cft test run all --stage verify --verbose --test-dir test/integration']
36-
- id: destroy
37+
args: ['/bin/bash', '-c', 'cft test run TestMinimalModule --stage verify --verbose --test-dir test/integration']
38+
- id: destroy-TestMinimalModule
3739
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
38-
args: ['/bin/bash', '-c', 'cft test run all --stage teardown --verbose --test-dir test/integration']
40+
args: ['/bin/bash', '-c', 'cft test run TestMinimalModule --stage teardown --verbose --test-dir test/integration']
41+
- id: converge-TestMemcache
42+
waitFor:
43+
- create
44+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
45+
args: ['/bin/bash', '-c', 'cft test run TestMemcache --stage apply --verbose --test-dir test/integration']
46+
- id: verify-TestMemcache
47+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
48+
args: ['/bin/bash', '-c', 'cft test run TestMemcache --stage verify --verbose --test-dir test/integration']
49+
- id: destroy-TestMemcache
50+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
51+
args: ['/bin/bash', '-c', 'cft test run TestMemcache --stage teardown --verbose --test-dir test/integration']
52+
- id: converge-TestRedis
53+
waitFor:
54+
- create
55+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
56+
args: ['/bin/bash', '-c', 'cft test run TestRedis --stage apply --verbose --test-dir test/integration']
57+
- id: verify-TestRedis
58+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
59+
args: ['/bin/bash', '-c', 'cft test run TestRedis --stage verify --verbose --test-dir test/integration']
60+
- id: destroy-TestRedis
61+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
62+
args: ['/bin/bash', '-c', 'cft test run TestRedis --stage teardown --verbose --test-dir test/integration']
63+
- id: converge-TestRedisCluster
64+
waitFor:
65+
- create
66+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
67+
args: ['/bin/bash', '-c', 'cft test run TestRedisCluster --stage apply --verbose --test-dir test/integration']
68+
- id: verify-TestRedisCluster
69+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
70+
args: ['/bin/bash', '-c', 'cft test run TestRedisCluster --stage verify --verbose --test-dir test/integration']
71+
- id: destroy-TestRedisCluster
72+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
73+
args: ['/bin/bash', '-c', 'cft test run TestRedisCluster --stage teardown --verbose --test-dir test/integration']
74+
- id: converge-TestValkeyCluster
75+
waitFor:
76+
- destroy-TestRedisCluster
77+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
78+
args: ['/bin/bash', '-c', 'cft test run TestValkeyCluster --stage apply --verbose --test-dir test/integration']
79+
- id: verify-TestValkeyCluster
80+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
81+
args: ['/bin/bash', '-c', 'cft test run TestValkeyCluster --stage verify --verbose --test-dir test/integration']
82+
- id: destroy-TestValkeyCluster
83+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
84+
args: ['/bin/bash', '-c', 'cft test run TestValkeyCluster --stage teardown --verbose --test-dir test/integration']
3985
tags:
4086
- 'ci'
4187
- 'integration'

examples/redis-cluster/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,9 @@ module "redis_cluster" {
6161
maxmemory-policy = "volatile-ttl"
6262
}
6363

64-
depends_on = [module.test_vpc]
64+
depends_on = [
65+
module.test_vpc,
66+
module.enable_apis,
67+
google_project_iam_member.network_connectivity_sa,
68+
]
6569
}

examples/valkey/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Valkey Test
2+
3+
This test will create a new valkey cluster.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| project\_id | Google cloud project id to create valkey cluster. | `string` | n/a | yes |
11+
12+
## Outputs
13+
14+
| Name | Description |
15+
|------|-------------|
16+
| authorization\_mode | The valkey cluster authorization mode |
17+
| cluster | The valkey cluster created |
18+
| cluster\_id | The valkey cluster instance ID |
19+
| cluster\_name | The valkey cluster name |
20+
| cluster\_region | The valkey cluster region |
21+
| node\_type | The valkey cluster node type |
22+
| replica\_count | The valkey cluster replica count |
23+
| shard\_count | The valkey cluster shard count |
24+
| size\_gb | The valkey cluster size |
25+
| transit\_encryption\_mode | The valkey cluster transit encryption mode |
26+
27+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/valkey/iam.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
## Enable Service Identity and assign Network Connectivity Service Agent role
18+
## https://cloud.google.com/vpc/docs/configure-service-connection-policies#configure-service-project
19+
20+
resource "google_project_service_identity" "network_connectivity_sa" {
21+
provider = google-beta
22+
23+
project = var.project_id
24+
service = "networkconnectivity.googleapis.com"
25+
}
26+
27+
resource "google_project_iam_member" "network_connectivity_sa" {
28+
project = var.project_id
29+
role = "roles/networkconnectivity.serviceAgent"
30+
member = "serviceAccount:${google_project_service_identity.network_connectivity_sa.email}"
31+
}

examples/valkey/main.tf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module "enable_apis" {
18+
source = "terraform-google-modules/project-factory/google//modules/project_services"
19+
version = "~> 17.0"
20+
21+
project_id = var.project_id
22+
enable_apis = true
23+
24+
disable_services_on_destroy = false
25+
disable_dependent_services = false
26+
27+
activate_apis = [
28+
"memorystore.googleapis.com",
29+
"serviceconsumermanagement.googleapis.com",
30+
"networkconnectivity.googleapis.com",
31+
"compute.googleapis.com",
32+
]
33+
}
34+
35+
36+
module "valkey_cluster" {
37+
source = "terraform-google-modules/memorystore/google//modules/valkey"
38+
version = "~> 11.0"
39+
40+
41+
instance_id = "test-valkey-cluster"
42+
project_id = var.project_id
43+
location = "us-central1"
44+
node_type = "HIGHMEM_MEDIUM"
45+
deletion_protection_enabled = false
46+
engine_version = "VALKEY_8_0"
47+
48+
network = local.network_name
49+
50+
service_connection_policies = {
51+
test-net-valkey-cluster-scp = {
52+
subnet_names = [
53+
"valkey-subnet-100",
54+
"valkey-subnet-101",
55+
]
56+
}
57+
}
58+
59+
persistence_config = {
60+
mode = "RDB"
61+
rdb_config = {
62+
rdb_snapshot_period = "ONE_HOUR"
63+
rdb_snapshot_start_time = "2024-10-02T15:01:23Z"
64+
}
65+
}
66+
67+
engine_configs = {
68+
maxmemory-policy = "volatile-ttl"
69+
}
70+
71+
depends_on = [
72+
module.test_vpc,
73+
module.enable_apis,
74+
google_project_iam_member.network_connectivity_sa,
75+
]
76+
}

examples/valkey/network.tf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
locals {
18+
network_name = "test-valkey-network"
19+
}
20+
21+
module "test_vpc" {
22+
source = "terraform-google-modules/network/google"
23+
version = "~> 9.2"
24+
project_id = var.project_id
25+
network_name = local.network_name
26+
mtu = 1460
27+
28+
subnets = [
29+
{
30+
subnet_name = "valkey-subnet-100"
31+
subnet_ip = "10.10.100.0/24"
32+
subnet_region = "us-central1"
33+
},
34+
{
35+
subnet_name = "valkey-subnet-101"
36+
subnet_ip = "10.10.101.0/24"
37+
subnet_region = "us-central1"
38+
},
39+
{
40+
subnet_name = "valkey-subnet-102"
41+
subnet_ip = "10.10.102.0/24"
42+
subnet_region = "us-east1"
43+
},
44+
]
45+
}

examples/valkey/outputs.tf

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "cluster_id" {
18+
description = "The valkey cluster instance ID"
19+
value = module.valkey_cluster.id
20+
}
21+
22+
output "size_gb" {
23+
description = "The valkey cluster size"
24+
value = module.valkey_cluster.valkey_cluster.node_config[0].size_gb
25+
}
26+
27+
output "cluster_region" {
28+
description = "The valkey cluster region"
29+
value = module.valkey_cluster.valkey_cluster.location
30+
}
31+
32+
output "replica_count" {
33+
description = "The valkey cluster replica count"
34+
value = module.valkey_cluster.valkey_cluster.replica_count
35+
}
36+
37+
output "transit_encryption_mode" {
38+
description = "The valkey cluster transit encryption mode"
39+
value = module.valkey_cluster.valkey_cluster.transit_encryption_mode
40+
}
41+
42+
output "cluster_name" {
43+
description = "The valkey cluster name"
44+
value = module.valkey_cluster.valkey_cluster.instance_id
45+
}
46+
47+
output "shard_count" {
48+
description = "The valkey cluster shard count"
49+
value = module.valkey_cluster.valkey_cluster.shard_count
50+
}
51+
52+
output "authorization_mode" {
53+
description = "The valkey cluster authorization mode"
54+
value = module.valkey_cluster.valkey_cluster.authorization_mode
55+
}
56+
57+
output "node_type" {
58+
description = "The valkey cluster node type"
59+
value = module.valkey_cluster.valkey_cluster.node_type
60+
}
61+
62+
output "cluster" {
63+
description = "The valkey cluster created"
64+
value = module.valkey_cluster
65+
}

examples/valkey/variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
description = "Google cloud project id to create valkey cluster."
19+
type = string
20+
}

0 commit comments

Comments
 (0)