Skip to content

Commit

Permalink
feat: add persistence configuration for Redis (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusch authored Feb 21, 2023
1 parent a1058c1 commit 103c794
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module "memorystore" {
| maintenance\_policy | The maintenance policy for an instance. | <pre>object({<br> day = string<br> start_time = object({<br> hours = number<br> minutes = number<br> seconds = number<br> nanos = number<br> })<br> })</pre> | `null` | no |
| 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 |
| 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 |
Expand Down
4 changes: 4 additions & 0 deletions examples/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ module "memstore" {
transit_encryption_mode = "SERVER_AUTHENTICATION"
authorized_network = module.test-vpc-module.network_id
memory_size_gb = 1
persistence_config = {
persistence_mode = "RDB"
rdb_snapshot_period = "ONE_HOUR"
}
}
8 changes: 8 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ resource "google_redis_instance" "default" {
}
}
}

dynamic "persistence_config" {
for_each = var.persistence_config != null ? [var.persistence_config] : []
content {
persistence_mode = persistence_config.value["persistence_mode"]
rdb_snapshot_period = persistence_config.value["rdb_snapshot_period"]
}
}
}

module "enable_apis" {
Expand Down
10 changes: 9 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,17 @@ variable "maintenance_policy" {
default = null
}


variable "customer_managed_key" {
description = "Default encryption key to apply to the Redis instance. Defaults to null (Google-managed)."
type = string
default = null
}

variable "persistence_config" {
description = "The Redis persistence configuration parameters. https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#persistenceconfig"
type = object({
persistence_mode = string
rdb_snapshot_period = string
})
default = null
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {

google = {
source = "hashicorp/google"
version = ">= 4.28.0, < 5.0"
version = ">= 4.38.0, < 5.0"
}
}

Expand Down

0 comments on commit 103c794

Please sign in to comment.