diff --git a/README.md b/README.md index dcbc37b..e422a35 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,86 @@ module "elasticache" { } ``` +### Serverless Cache + +```hcl +module "elasticache" { + source = "terraform-aws-modules/elasticache/aws//modules/serverless-cache" + + engine = "redis" + cache_name = "example-serverless-cache" + + cache_usage_limits = { + data_storage = { + maximum = 2 + } + ecpu_per_second = { + maximum = 1000 + } + } + + daily_snapshot_time = "22:00" + description = "example-serverless-cache serverless cluster" + kms_key_id = aws_kms_key.this.arn + major_engine_version = "7" + security_group_ids = [module.sg.security_group_id] + + snapshot_retention_limit = 7 + subnet_ids = module.vpc.private_subnets + + user_group_id = module.cache_user_group.group_id +} +``` + +### Valkey Replication Group + +```hcl +module "elasticache" { + source = "terraform-aws-modules/elasticache/aws" + + replication_group_id = local.name + + engine = "valkey" + engine_version = "7.2" + node_type = "cache.t4g.small" + + transit_encryption_enabled = true + auth_token = "PickSomethingMoreSecure123!" + maintenance_window = "sun:05:00-sun:09:00" + apply_immediately = true + + # Security Group + vpc_id = module.vpc.vpc_id + security_group_rules = { + ingress_vpc = { + # Default type is `ingress` + # Default port is based on the default engine port + description = "VPC traffic" + cidr_ipv4 = module.vpc.vpc_cidr_block + } + } + + # Subnet Group + subnet_group_name = local.name + subnet_group_description = "Valkey replication group subnet group" + subnet_ids = module.vpc.private_subnets + + # Parameter Group + create_parameter_group = true + parameter_group_name = local.name + parameter_group_family = "valkey7" + parameter_group_description = "Valkey replication group parameter group" + parameters = [ + { + name = "latency-tracking" + value = "yes" + } + ] + + tags = local.tags +} +``` + ## Examples Examples codified under the [`examples`](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples) are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you! @@ -277,6 +357,8 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module - [Redis Cluster Mode](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples/redis-cluster-mode) - [Redis Global Replication Group](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples/redis-global-replication-group) - [Redis Replication Group](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples/redis-replication-group) +- [Serverless Cache](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples/serverless-cache) +- [Valkey Replication Group](https://github.com/terraform-aws-modules/terraform-aws-elasticache/tree/master/examples/valkey-replication-group) ## Requirements @@ -284,14 +366,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | | [random](#requirement\_random) | >= 3.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | | [random](#provider\_random) | >= 3.0 | ## Modules @@ -322,7 +404,7 @@ No modules. | [at\_rest\_encryption\_enabled](#input\_at\_rest\_encryption\_enabled) | Whether to enable encryption at rest | `bool` | `true` | no | | [auth\_token](#input\_auth\_token) | The password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true` | `string` | `null` | no | | [auth\_token\_update\_strategy](#input\_auth\_token\_update\_strategy) | Strategy to use when updating the `auth_token`. Valid values are `SET`, `ROTATE`, and `DELETE`. Defaults to `ROTATE` | `string` | `null` | no | -| [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Only supported for engine type `redis` and if the engine version is 6 or higher. Defaults to `true` | `bool` | `null` | no | +| [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Only supported for engine type `redis` and `valkey` and if the engine version is 6 or higher. Defaults to `true` | `bool` | `null` | no | | [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If true, Multi-AZ is enabled for this replication group. If false, Multi-AZ is disabled for this replication group. Must be enabled for Redis (cluster mode enabled) replication groups | `bool` | `null` | no | | [availability\_zone](#input\_availability\_zone) | Availability Zone for the cache cluster. If you want to create cache nodes in multi-az, use `preferred_availability_zones` instead | `string` | `null` | no | | [az\_mode](#input\_az\_mode) | Whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are `single-az` or `cross-az`, default is `single-az` | `string` | `null` | no | @@ -339,13 +421,13 @@ No modules. | [create\_subnet\_group](#input\_create\_subnet\_group) | Determines whether the Elasticache subnet group will be created or not | `bool` | `true` | no | | [data\_tiering\_enabled](#input\_data\_tiering\_enabled) | Enables data tiering. Data tiering is only supported for replication groups using the `r6gd` node type. This parameter must be set to true when using `r6gd` nodes | `bool` | `null` | no | | [description](#input\_description) | User-created description for the replication group | `string` | `null` | no | -| [engine](#input\_engine) | Name of the cache engine to be used for this cache cluster. Valid values are `memcached` or `redis` | `string` | `"redis"` | no | +| [engine](#input\_engine) | Name of the cache engine to be used for this cache cluster. Valid values are `memcached`, `redis`, or `valkey` | `string` | `"redis"` | no | | [engine\_version](#input\_engine\_version) | Version number of the cache engine to be used. If not set, defaults to the latest version | `string` | `null` | no | | [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | (Redis only) Name of your final cluster snapshot. If omitted, no final snapshot will be made | `string` | `null` | no | | [global\_replication\_group\_id](#input\_global\_replication\_group\_id) | The ID of the global replication group to which this replication group should belong | `string` | `null` | no | | [ip\_discovery](#input\_ip\_discovery) | The IP version to advertise in the discovery protocol. Valid values are `ipv4` or `ipv6` | `string` | `null` | no | | [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if `at_rest_encryption_enabled = true` | `string` | `null` | no | -| [log\_delivery\_configuration](#input\_log\_delivery\_configuration) | (Redis only) Specifies the destination and format of Redis SLOWLOG or Redis Engine Log | `any` |
{
"slow-log": {
"destination_type": "cloudwatch-logs",
"log_format": "json"
}
}
| no | +| [log\_delivery\_configuration](#input\_log\_delivery\_configuration) | (Redis OSS or Valkey) Specifies the destination and format of Redis OSS/Valkey SLOWLOG or Redis OSS/Valkey Engine Log | `any` |
{
"slow-log": {
"destination_type": "cloudwatch-logs",
"log_format": "json"
}
}
| no | | [maintenance\_window](#input\_maintenance\_window) | Specifies the weekly time range for when maintenance on the cache cluster is performed. The format is `ddd:hh24:mi-ddd:hh24:mi` (24H Clock UTC) | `string` | `null` | no | | [multi\_az\_enabled](#input\_multi\_az\_enabled) | Specifies whether to enable Multi-AZ Support for the replication group. If true, `automatic_failover_enabled` must also be enabled. Defaults to `false` | `bool` | `false` | no | | [network\_type](#input\_network\_type) | The IP versions for cache cluster connections. Valid values are `ipv4`, `ipv6` or `dual_stack` | `string` | `null` | no | diff --git a/examples/memcached-cluster/README.md b/examples/memcached-cluster/README.md index 71fe41a..16ced47 100644 --- a/examples/memcached-cluster/README.md +++ b/examples/memcached-cluster/README.md @@ -20,13 +20,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/examples/memcached-cluster/versions.tf b/examples/memcached-cluster/versions.tf index 0615775..0f48a6c 100644 --- a/examples/memcached-cluster/versions.tf +++ b/examples/memcached-cluster/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/redis-cluster-mode/README.md b/examples/redis-cluster-mode/README.md index 9d1a578..9bc003f 100644 --- a/examples/redis-cluster-mode/README.md +++ b/examples/redis-cluster-mode/README.md @@ -22,13 +22,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/examples/redis-cluster-mode/versions.tf b/examples/redis-cluster-mode/versions.tf index 0615775..0f48a6c 100644 --- a/examples/redis-cluster-mode/versions.tf +++ b/examples/redis-cluster-mode/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/redis-cluster/README.md b/examples/redis-cluster/README.md index 1d3d4f4..19b1c33 100644 --- a/examples/redis-cluster/README.md +++ b/examples/redis-cluster/README.md @@ -20,13 +20,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/examples/redis-cluster/versions.tf b/examples/redis-cluster/versions.tf index 0615775..0f48a6c 100644 --- a/examples/redis-cluster/versions.tf +++ b/examples/redis-cluster/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/redis-global-replication-group/README.md b/examples/redis-global-replication-group/README.md index 7ee97b6..369e352 100644 --- a/examples/redis-global-replication-group/README.md +++ b/examples/redis-global-replication-group/README.md @@ -24,14 +24,14 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | -| [aws.euwest1](#provider\_aws.euwest1) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | +| [aws.euwest1](#provider\_aws.euwest1) | >= 5.73 | ## Modules diff --git a/examples/redis-global-replication-group/versions.tf b/examples/redis-global-replication-group/versions.tf index 0615775..0f48a6c 100644 --- a/examples/redis-global-replication-group/versions.tf +++ b/examples/redis-global-replication-group/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/redis-replication-group-with-cluster-replica/README.md b/examples/redis-replication-group-with-cluster-replica/README.md index 7c3b025..7f62c8a 100644 --- a/examples/redis-replication-group-with-cluster-replica/README.md +++ b/examples/redis-replication-group-with-cluster-replica/README.md @@ -20,13 +20,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/examples/redis-replication-group-with-cluster-replica/versions.tf b/examples/redis-replication-group-with-cluster-replica/versions.tf index 0615775..0f48a6c 100644 --- a/examples/redis-replication-group-with-cluster-replica/versions.tf +++ b/examples/redis-replication-group-with-cluster-replica/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/redis-replication-group/README.md b/examples/redis-replication-group/README.md index 75d8720..237289b 100644 --- a/examples/redis-replication-group/README.md +++ b/examples/redis-replication-group/README.md @@ -20,13 +20,13 @@ Note that this example may create resources which will incur monetary charges on | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/examples/redis-replication-group/versions.tf b/examples/redis-replication-group/versions.tf index 0615775..0f48a6c 100644 --- a/examples/redis-replication-group/versions.tf +++ b/examples/redis-replication-group/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/serverless-cache/main.tf b/examples/serverless-cache/main.tf index 6516453..6a0a9d7 100644 --- a/examples/serverless-cache/main.tf +++ b/examples/serverless-cache/main.tf @@ -45,6 +45,33 @@ module "serverless" { user_group_id = module.cache_user_group.group_id } +module "valkey_serverless" { + source = "../../modules/serverless-cache" + + engine = "valkey" + cache_name = "${local.name}-valkey" + + cache_usage_limits = { + data_storage = { + maximum = 2 + } + ecpu_per_second = { + maximum = 1000 + } + } + + daily_snapshot_time = "22:00" + description = "${local.name} valkey serverless cluster" + kms_key_id = aws_kms_key.this.arn + major_engine_version = "7" + security_group_ids = [module.sg.security_group_id] + + snapshot_retention_limit = 7 + subnet_ids = module.vpc.private_subnets + + user_group_id = module.cache_user_group.group_id +} + module "cache_user_group" { source = "../../modules/user-group" diff --git a/examples/serverless-cache/versions.tf b/examples/serverless-cache/versions.tf index 0615775..0f48a6c 100644 --- a/examples/serverless-cache/versions.tf +++ b/examples/serverless-cache/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/examples/valkey-replication-group/README.md b/examples/valkey-replication-group/README.md new file mode 100644 index 0000000..6e6a98a --- /dev/null +++ b/examples/valkey-replication-group/README.md @@ -0,0 +1,77 @@ +# ElastiCache example for Valkey Replication Group + +Configuration in this directory creates set of ElastiCaChe resources including replication group, subnet group and parameter group. + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Note that this example may create resources which will incur monetary charges on your AWS bill. Run `terraform destroy` when you no longer need these resources. + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0 | +| [aws](#requirement\_aws) | >= 5.73 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | >= 5.73 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [elasticache](#module\_elasticache) | ../../ | n/a | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | + +## Resources + +| Name | Type | +|------|------| +| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | + +## Inputs + +No inputs. + +## Outputs + +| Name | Description | +|------|-------------| +| [cloudwatch\_log\_group\_arn](#output\_cloudwatch\_log\_group\_arn) | Arn of cloudwatch log group created | +| [cloudwatch\_log\_group\_name](#output\_cloudwatch\_log\_group\_name) | Name of cloudwatch log group created | +| [cluster\_address](#output\_cluster\_address) | (Memcached only) DNS name of the cache cluster without the port appended | +| [cluster\_arn](#output\_cluster\_arn) | The ARN of the ElastiCache Cluster | +| [cluster\_cache\_nodes](#output\_cluster\_cache\_nodes) | List of node objects including `id`, `address`, `port` and `availability_zone` | +| [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | (Memcached only) Configuration endpoint to allow host discovery | +| [cluster\_engine\_version\_actual](#output\_cluster\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine | +| [global\_replication\_group\_arn](#output\_global\_replication\_group\_arn) | ARN of the created ElastiCache Global Replication Group | +| [global\_replication\_group\_engine\_version\_actual](#output\_global\_replication\_group\_engine\_version\_actual) | The full version number of the cache engine running on the members of this global replication group | +| [global\_replication\_group\_id](#output\_global\_replication\_group\_id) | ID of the ElastiCache Global Replication Group | +| [global\_replication\_group\_node\_groups](#output\_global\_replication\_group\_node\_groups) | Set of node groups (shards) on the global replication group | +| [parameter\_group\_arn](#output\_parameter\_group\_arn) | The AWS ARN associated with the parameter group | +| [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group name | +| [replication\_group\_arn](#output\_replication\_group\_arn) | ARN of the created ElastiCache Replication Group | +| [replication\_group\_configuration\_endpoint\_address](#output\_replication\_group\_configuration\_endpoint\_address) | Address of the replication group configuration endpoint when cluster mode is enabled | +| [replication\_group\_engine\_version\_actual](#output\_replication\_group\_engine\_version\_actual) | Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine | +| [replication\_group\_id](#output\_replication\_group\_id) | ID of the ElastiCache Replication Group | +| [replication\_group\_member\_clusters](#output\_replication\_group\_member\_clusters) | Identifiers of all the nodes that are part of this replication group | +| [replication\_group\_primary\_endpoint\_address](#output\_replication\_group\_primary\_endpoint\_address) | Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled | +| [replication\_group\_reader\_endpoint\_address](#output\_replication\_group\_reader\_endpoint\_address) | Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled | +| [security\_group\_arn](#output\_security\_group\_arn) | Amazon Resource Name (ARN) of the security group | +| [security\_group\_id](#output\_security\_group\_id) | ID of the security group | +| [subnet\_group\_name](#output\_subnet\_group\_name) | The ElastiCache subnet group name | + + +Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/LICENSE). diff --git a/examples/valkey-replication-group/main.tf b/examples/valkey-replication-group/main.tf new file mode 100644 index 0000000..0cba188 --- /dev/null +++ b/examples/valkey-replication-group/main.tf @@ -0,0 +1,86 @@ +provider "aws" { + region = local.region +} + +data "aws_availability_zones" "available" {} + +locals { + region = "eu-west-1" + name = "ex-${basename(path.cwd)}" + + vpc_cidr = "10.0.0.0/16" + azs = slice(data.aws_availability_zones.available.names, 0, 3) + + tags = { + Name = local.name + Example = local.name + Repository = "https://github.com/terraform-aws-modules/terraform-aws-elasticache" + } +} + +################################################################################ +# ElastiCache Module +################################################################################ + +module "elasticache" { + source = "../../" + + replication_group_id = local.name + + engine = "valkey" + engine_version = "7.2" + node_type = "cache.t4g.small" + + transit_encryption_enabled = true + auth_token = "PickSomethingMoreSecure123!" + maintenance_window = "sun:05:00-sun:09:00" + apply_immediately = true + + # Security Group + vpc_id = module.vpc.vpc_id + security_group_rules = { + ingress_vpc = { + # Default type is `ingress` + # Default port is based on the default engine port + description = "VPC traffic" + cidr_ipv4 = module.vpc.vpc_cidr_block + } + } + + # Subnet Group + subnet_group_name = local.name + subnet_group_description = "${title(local.name)} subnet group" + subnet_ids = module.vpc.private_subnets + + # Parameter Group + create_parameter_group = true + parameter_group_name = local.name + parameter_group_family = "valkey7" + parameter_group_description = "${title(local.name)} parameter group" + parameters = [ + { + name = "latency-tracking" + value = "yes" + } + ] + + tags = local.tags +} + +################################################################################ +# Supporting Resources +################################################################################ + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 5.0" + + name = local.name + cidr = local.vpc_cidr + + azs = local.azs + public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)] + private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)] + + tags = local.tags +} diff --git a/examples/valkey-replication-group/outputs.tf b/examples/valkey-replication-group/outputs.tf new file mode 100644 index 0000000..a3a563b --- /dev/null +++ b/examples/valkey-replication-group/outputs.tf @@ -0,0 +1,142 @@ +################################################################################ +# Cluster +################################################################################ + +output "cluster_arn" { + description = "The ARN of the ElastiCache Cluster" + value = module.elasticache.cluster_arn +} + +output "cluster_engine_version_actual" { + description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine" + value = module.elasticache.cluster_engine_version_actual +} + +output "cluster_cache_nodes" { + description = "List of node objects including `id`, `address`, `port` and `availability_zone`" + value = module.elasticache.cluster_cache_nodes +} + +output "cluster_address" { + description = "(Memcached only) DNS name of the cache cluster without the port appended" + value = module.elasticache.cluster_address +} + +output "cluster_configuration_endpoint" { + description = "(Memcached only) Configuration endpoint to allow host discovery" + value = module.elasticache.cluster_configuration_endpoint +} + +################################################################################ +# Replication Group +################################################################################ + +output "replication_group_arn" { + description = "ARN of the created ElastiCache Replication Group" + value = module.elasticache.replication_group_arn +} + +output "replication_group_engine_version_actual" { + description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine" + value = module.elasticache.replication_group_engine_version_actual +} + +output "replication_group_configuration_endpoint_address" { + description = "Address of the replication group configuration endpoint when cluster mode is enabled" + value = module.elasticache.replication_group_configuration_endpoint_address +} + +output "replication_group_id" { + description = "ID of the ElastiCache Replication Group" + value = module.elasticache.replication_group_id +} + +output "replication_group_member_clusters" { + description = "Identifiers of all the nodes that are part of this replication group" + value = module.elasticache.replication_group_member_clusters +} + +output "replication_group_primary_endpoint_address" { + description = "Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled" + value = module.elasticache.replication_group_primary_endpoint_address +} + +output "replication_group_reader_endpoint_address" { + description = "Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled" + value = module.elasticache.replication_group_reader_endpoint_address +} + +################################################################################ +# Global Replication Group +################################################################################ + +output "global_replication_group_id" { + description = "ID of the ElastiCache Global Replication Group" + value = module.elasticache.global_replication_group_id +} + +output "global_replication_group_arn" { + description = "ARN of the created ElastiCache Global Replication Group" + value = module.elasticache.global_replication_group_arn +} + +output "global_replication_group_engine_version_actual" { + description = "The full version number of the cache engine running on the members of this global replication group" + value = module.elasticache.global_replication_group_engine_version_actual +} + +output "global_replication_group_node_groups" { + description = "Set of node groups (shards) on the global replication group" + value = module.elasticache.global_replication_group_node_groups +} + +################################################################################ +# CloudWatch Log Group +################################################################################ + +output "cloudwatch_log_group_name" { + description = "Name of cloudwatch log group created" + value = module.elasticache.cloudwatch_log_group_name +} + +output "cloudwatch_log_group_arn" { + description = "Arn of cloudwatch log group created" + value = module.elasticache.cloudwatch_log_group_arn +} + +################################################################################ +# Parameter Group +################################################################################ + +output "parameter_group_arn" { + description = "The AWS ARN associated with the parameter group" + value = module.elasticache.parameter_group_arn +} + +output "parameter_group_id" { + description = "The ElastiCache parameter group name" + value = module.elasticache.parameter_group_id +} + +################################################################################ +# Subnet Group +################################################################################ + +output "subnet_group_name" { + description = "The ElastiCache subnet group name" + value = module.elasticache.subnet_group_name +} + +################################################################################ +# Security Group +################################################################################ + +output "security_group_arn" { + description = "Amazon Resource Name (ARN) of the security group" + value = module.elasticache.security_group_arn +} + +output "security_group_id" { + description = "ID of the security group" + value = module.elasticache.security_group_id +} diff --git a/examples/valkey-replication-group/variables.tf b/examples/valkey-replication-group/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/valkey-replication-group/versions.tf b/examples/valkey-replication-group/versions.tf new file mode 100644 index 0000000..0f48a6c --- /dev/null +++ b/examples/valkey-replication-group/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.73" + } + } +} diff --git a/main.tf b/main.tf index f78027c..69a3b9b 100644 --- a/main.tf +++ b/main.tf @@ -2,6 +2,11 @@ locals { # https://github.com/hashicorp/terraform-provider-aws/blob/3c4cb52c5dc2c09e10e5a717f73d1d8bc4186e87/internal/service/elasticache/cluster.go#L271 in_replication_group = var.replication_group_id != null + # elasticache clusters currently do not support engine type valkey + # TODO: remove this local `create_cluster` conditional once this bug is addressed: + # https://github.com/hashicorp/terraform-provider-aws/issues/39905 + create_cluster = var.create_cluster && var.engine != "valkey" ? true : false + security_group_ids = local.create_security_group ? concat(var.security_group_ids, [aws_security_group.this[0].id]) : var.security_group_ids port = var.engine == "memcached" ? 11211 : 6379 @@ -13,7 +18,7 @@ locals { ################################################################################ resource "aws_elasticache_cluster" "this" { - count = var.create && var.create_cluster ? 1 : 0 + count = var.create && local.create_cluster ? 1 : 0 apply_immediately = var.apply_immediately auto_minor_version_upgrade = var.auto_minor_version_upgrade @@ -86,7 +91,7 @@ resource "aws_elasticache_replication_group" "this" { kms_key_id = var.at_rest_encryption_enabled ? var.kms_key_arn : null dynamic "log_delivery_configuration" { - for_each = { for k, v in var.log_delivery_configuration : k => v if var.engine == "redis" } + for_each = { for k, v in var.log_delivery_configuration : k => v if var.engine != "memcached" } content { destination = try(log_delivery_configuration.value.create_cloudwatch_log_group, true) && log_delivery_configuration.value.destination_type == "cloudwatch-logs" ? aws_cloudwatch_log_group.this[log_delivery_configuration.key].name : log_delivery_configuration.value.destination diff --git a/modules/serverless-cache/README.md b/modules/serverless-cache/README.md index e4605fb..fb644c2 100644 --- a/modules/serverless-cache/README.md +++ b/modules/serverless-cache/README.md @@ -60,13 +60,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/modules/serverless-cache/versions.tf b/modules/serverless-cache/versions.tf index 0615775..0f48a6c 100644 --- a/modules/serverless-cache/versions.tf +++ b/modules/serverless-cache/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/modules/user-group/README.md b/modules/user-group/README.md index b1584fe..6e4305e 100644 --- a/modules/user-group/README.md +++ b/modules/user-group/README.md @@ -66,13 +66,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.71 | +| [aws](#requirement\_aws) | >= 5.73 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.71 | +| [aws](#provider\_aws) | >= 5.73 | ## Modules diff --git a/modules/user-group/versions.tf b/modules/user-group/versions.tf index 0615775..0f48a6c 100644 --- a/modules/user-group/versions.tf +++ b/modules/user-group/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } } } diff --git a/variables.tf b/variables.tf index 59649be..55b36ba 100644 --- a/variables.tf +++ b/variables.tf @@ -27,7 +27,7 @@ variable "apply_immediately" { } variable "auto_minor_version_upgrade" { - description = "Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Only supported for engine type `redis` and if the engine version is 6 or higher. Defaults to `true`" + description = "Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Only supported for engine type `redis` and `valkey` and if the engine version is 6 or higher. Defaults to `true`" type = bool default = null } @@ -57,7 +57,7 @@ variable "cluster_id" { } variable "engine" { - description = "Name of the cache engine to be used for this cache cluster. Valid values are `memcached` or `redis`" + description = "Name of the cache engine to be used for this cache cluster. Valid values are `memcached`, `redis`, or `valkey`" type = string default = "redis" } @@ -81,7 +81,7 @@ variable "ip_discovery" { } variable "log_delivery_configuration" { - description = "(Redis only) Specifies the destination and format of Redis SLOWLOG or Redis Engine Log" + description = "(Redis OSS or Valkey) Specifies the destination and format of Redis OSS/Valkey SLOWLOG or Redis OSS/Valkey Engine Log" type = any default = { slow-log = { diff --git a/versions.tf b/versions.tf index 0bf905c..648b57a 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.71" + version = ">= 5.73" } random = { source = "hashicorp/random"