Skip to content

Create parameter group description variable #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ terraform.tfstate
*.tfstate*
terraform.tfvars
*.terraform.lock.hcl
*vscode
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
args: ['--allow-missing-credentials']
- id: trailing-whitespace
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.80.0
rev: v1.82.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand Down
41 changes: 38 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,38 @@ All notable changes to this project will be documented in this file.
<a name="unreleased"></a>
## [Unreleased]

- Use t4g instance sizes for examples + Update minimum redis version from 5.x to 6.x
- Update terraform versions
- chore(snapshot): Allow restore from a snapshot ([#46](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/46))
- feat(subnet_group): Allow to pass an existing subnet group ([#44](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/44))


<a name="3.4.0"></a>
## [3.4.0] - 2023-07-14

- Remove provider max version constraints ([#47](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/47))


<a name="3.3.0"></a>
## [3.3.0] - 2023-04-20

- Add User Group ID support ([#39](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/39))
- fix: Type of multi_az_enabled variable ([#36](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/36))
- Allow to skip sg egress rules creation ([#40](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/40))


<a name="3.1.4"></a>
## [3.1.4] - 2022-07-13



<a name="3.2.0"></a>
## [3.2.0] - 2022-07-13

- Documentation + Examples cleanup ([#33](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/33))


<a name="3.1.3"></a>
## [3.1.3] - 2022-07-12

- Add Data Tiering support ([#32](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/32))


Expand Down Expand Up @@ -125,7 +155,12 @@ All notable changes to this project will be documented in this file.
- Initial commit of docs


[Unreleased]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.2...HEAD
[Unreleased]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.4.0...HEAD
[3.4.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.3.0...3.4.0
[3.3.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.4...3.3.0
[3.1.4]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.2.0...3.1.4
[3.2.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.3...3.2.0
[3.1.3]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.1...3.1.2
[3.1.1]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.0.0...3.1.0
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module "redis" {
num_cache_clusters = 2
node_type = "cache.t4g.small"

engine_version = "6.x"
engine_version = "7.0"
port = 6379
maintenance_window = "mon:03:00-mon:04:00"
snapshot_window = "04:00-06:00"
Expand All @@ -35,7 +35,7 @@ module "redis" {
auth_token = "1234567890asdfghjkl"

apply_immediately = true
family = "redis6.x"
family = "redis7"
description = "Test elasticache redis."

subnet_ids = module.vpc.private_subnets
Expand Down Expand Up @@ -81,14 +81,14 @@ Module managed by [uMotif](https://github.com/umotif-public/)
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.11 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.8.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.12.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.3.2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.8.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.12.0 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.3.2 |

## Modules
Expand Down Expand Up @@ -139,6 +139,7 @@ No modules.
| <a name="input_num_cache_clusters"></a> [num\_cache\_clusters](#input\_num\_cache\_clusters) | The number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. Conflicts with num\_node\_groups. | `number` | `1` | no |
| <a name="input_num_node_groups"></a> [num\_node\_groups](#input\_num\_node\_groups) | Specify the number of node groups (shards) for this Redis replication group. Changing this number will trigger an online resizing operation before other settings modifications. | `number` | `0` | no |
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Redis parameters to apply. Note that parameters may differ from one Redis family to another | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the ElastiCache parameter group | `string` | `null` | no |
| <a name="input_port"></a> [port](#input\_port) | The port number on which each of the cache nodes will accept connections. | `number` | `6379` | no |
| <a name="input_preferred_cache_cluster_azs"></a> [preferred\_cache\_cluster\_azs](#input\_preferred\_cache\_cluster\_azs) | A list of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is not important. | `list(string)` | `null` | no |
| <a name="input_replicas_per_node_group"></a> [replicas\_per\_node\_group](#input\_replicas\_per\_node\_group) | Specify the number of replica nodes in each node group. Valid values are 0 to 5. Changing this number will trigger an online resizing operation before other settings modifications. | `number` | `0` | no |
Expand Down
16 changes: 8 additions & 8 deletions examples/redis-basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ module "redis" {
num_cache_clusters = 2
node_type = "cache.t4g.small"

engine_version = "6.x"
port = 6379
maintenance_window = "mon:03:00-mon:04:00"
snapshot_window = "04:00-06:00"
snapshot_retention_limit = 7
final_snapshot_identifier = "redis-final-snapshot-name"
engine_version = "7.0"
port = 6379
maintenance_window = "mon:03:00-mon:04:00"
snapshot_window = "04:00-06:00"
snapshot_retention_limit = 7

automatic_failover_enabled = true
multi_az_enabled = true
Expand All @@ -48,7 +47,7 @@ module "redis" {
auth_token = "1234567890asdfghjkl"

apply_immediately = true
family = "redis6.x"
family = "redis7"
description = "Test elasticache redis."

subnet_ids = data.aws_subnets.all.ids
Expand All @@ -75,6 +74,7 @@ module "redis" {
]

tags = {
Project = "Test"
Project = "Github"
Environment = "test"
}
}
11 changes: 9 additions & 2 deletions examples/redis-basic/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ terraform {
required_version = ">= 1.0.11"

required_providers {
aws = "~> 5.1"
random = "~> 3.3"
aws = {
source = "hashicorp/aws"
version = "~> 5"
}

random = {
source = "hashicorp/random"
version = "~> 3.3"
}
}
}
7 changes: 4 additions & 3 deletions examples/redis-clustered-mode/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module "redis" {
replicas_per_node_group = 1
num_node_groups = 2

engine_version = "6.x"
engine_version = "7.0"
port = 6379
maintenance_window = "mon:03:00-mon:04:00"
snapshot_window = "04:00-06:00"
Expand All @@ -43,7 +43,7 @@ module "redis" {
auth_token = "1234567890asdfghjkl"

apply_immediately = true
family = "redis6.x"
family = "redis7"
description = "Test elasticache redis."

subnet_ids = data.aws_subnets.all.ids
Expand All @@ -59,6 +59,7 @@ module "redis" {
]

tags = {
Project = "Test"
Project = "Github"
Environment = "test"
}
}
11 changes: 9 additions & 2 deletions examples/redis-clustered-mode/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ terraform {
required_version = ">= 1.0.11"

required_providers {
aws = "~> 5.1"
random = "~> 3.3"
aws = {
source = "hashicorp/aws"
version = "~> 5"
}

random = {
source = "hashicorp/random"
version = "~> 3.3"
}
}
}
14 changes: 12 additions & 2 deletions examples/redis-replication-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ module "redis_main" {

name_prefix = "redis-example-main"
num_cache_clusters = 2
node_type = "cache.m5.large"
node_type = "cache.m7g.large"
auth_token = "1234567890asdfghjkl"

subnet_ids = data.aws_subnets.main.ids
vpc_id = data.aws_vpc.main.id

tags = {
Project = "Github"
Environment = "test"
}
}

resource "aws_elasticache_global_replication_group" "this" {
Expand All @@ -62,7 +67,7 @@ module "redis_replica" {

name_prefix = "redis-example-replica"
num_cache_clusters = 2
node_type = "cache.m5.large"
node_type = "cache.m7g.large"
auth_token = "1234567890asdfghjkl"

subnet_ids = data.aws_subnets.replica.ids
Expand All @@ -71,4 +76,9 @@ module "redis_replica" {
global_replication_group_id = aws_elasticache_global_replication_group.this.global_replication_group_id

providers = { aws = aws.replica }

tags = {
Project = "Github"
Environment = "test"
}
}
11 changes: 9 additions & 2 deletions examples/redis-replication-group/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ terraform {
required_version = ">= 1.0.11"

required_providers {
aws = "~> 5.1"
random = "~> 3.3"
aws = {
source = "hashicorp/aws"
version = "~> 5"
}

random = {
source = "hashicorp/random"
version = "~> 3.3"
}
}
}
13 changes: 9 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "aws_elasticache_replication_group" "redis" {
num_node_groups = var.cluster_mode_enabled ? var.num_node_groups : null

user_group_ids = var.user_group_ids

dynamic "log_delivery_configuration" {
for_each = var.log_delivery_configuration

Expand Down Expand Up @@ -74,7 +75,7 @@ resource "random_id" "redis_pg" {
resource "aws_elasticache_parameter_group" "redis" {
name = "${var.name_prefix}-redis-${random_id.redis_pg.hex}"
family = var.family
description = var.description
description = var.parameter_group_description != null ? var.parameter_group_description : "Elasticache parameter group managed by Terraform"

dynamic "parameter" {
for_each = var.num_node_groups > 0 ? concat([{ name = "cluster-enabled", value = "yes" }], var.parameter) : var.parameter
Expand All @@ -84,18 +85,22 @@ resource "aws_elasticache_parameter_group" "redis" {
}
}

# Ignore changes to the description since it will try to recreate the resource
lifecycle {
create_before_destroy = true
ignore_changes = [
description,
]
}

tags = var.tags
}

resource "aws_elasticache_subnet_group" "redis" {
count = var.subnet_group_name == null && length(var.subnet_ids) > 0 ? 1 : 0
count = var.subnet_group_name == null && length(var.subnet_ids) > 0 ? 1 : 0

name = var.global_replication_group_id == null ? "${var.name_prefix}-redis-sg" : "${var.name_prefix}-redis-sg-replica"
subnet_ids = var.subnet_ids
description = var.description
description = "Elasticache subnet group for ${var.description}"

tags = var.tags
}
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,15 @@ variable "data_tiering_enabled" {
default = false
description = "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."
}

variable "user_group_ids" {
type = list(string)
default = null
description = "User Group ID to associate with the replication group"
}

variable "parameter_group_description" {
type = string
description = "The description of the ElastiCache parameter group"
default = null
}
11 changes: 9 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ terraform {
required_version = ">= 1.0.11"

required_providers {
aws = ">= 4.8.0"
random = ">= 3.3.2"
aws = {
source = "hashicorp/aws"
version = ">= 4.12.0"
}

random = {
source = "hashicorp/random"
version = ">= 3.3.2"
}
}
}