From c8540d6cea45cd7cfb61793838c097f14c64c0fd Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Fri, 11 Oct 2024 16:08:31 +0000 Subject: [PATCH 1/3] fix: Update CI workflow versions to latest (#9) --- .github/workflows/pr-title.yml | 2 +- .github/workflows/pre-commit.yml | 14 +++++++------- .pre-commit-config.yaml | 5 ++--- README.md | 4 ++-- examples/complete/README.md | 4 ++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 3973df4..1e50760 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -14,7 +14,7 @@ jobs: steps: # Please look up the latest version from # https://github.com/amannn/action-semantic-pull-request/releases - - uses: amannn/action-semantic-pull-request@v5.4.0 + - uses: amannn/action-semantic-pull-request@v5.5.3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c2632d1..a19ff83 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -7,8 +7,8 @@ on: - master env: - TERRAFORM_DOCS_VERSION: v0.16.0 - TFLINT_VERSION: v0.50.3 + TERRAFORM_DOCS_VERSION: v0.19.0 + TFLINT_VERSION: v0.53.0 jobs: collectInputs: @@ -45,14 +45,14 @@ jobs: - name: Terraform min/max versions id: minMax - uses: clowdhaus/terraform-min-max@v1.3.0 + uses: clowdhaus/terraform-min-max@v1.3.1 with: directory: ${{ matrix.directory }} - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} # Run only validate pre-commit check on min version supported if: ${{ matrix.directory != '.' }} - uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 with: terraform-version: ${{ steps.minMax.outputs.minVersion }} tflint-version: ${{ env.TFLINT_VERSION }} @@ -61,7 +61,7 @@ jobs: - name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }} # Run only validate pre-commit check on min version supported if: ${{ matrix.directory == '.' }} - uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 with: terraform-version: ${{ steps.minMax.outputs.minVersion }} tflint-version: ${{ env.TFLINT_VERSION }} @@ -88,10 +88,10 @@ jobs: - name: Terraform min/max versions id: minMax - uses: clowdhaus/terraform-min-max@v1.3.0 + uses: clowdhaus/terraform-min-max@v1.3.1 - name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }} - uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0 + uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1 with: terraform-version: ${{ steps.minMax.outputs.maxVersion }} tflint-version: ${{ env.TFLINT_VERSION }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 395404e..a6cd369 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.88.0 + rev: v1.96.1 hooks: - id: terraform_fmt - id: terraform_docs @@ -21,10 +21,9 @@ repos: - '--args=--only=terraform_required_providers' - '--args=--only=terraform_standard_module_structure' - '--args=--only=terraform_workspace_remote' - - '--args=--only=terraform_unused_required_providers' - id: terraform_validate - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-merge-conflict - id: end-of-file-fixer diff --git a/README.md b/README.md index 29791db..0332e8b 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module - [Complete](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples/complete) - + ## Requirements | Name | Version | @@ -206,7 +206,7 @@ No modules. | [subnet\_group\_id](#output\_subnet\_group\_id) | Name of the subnet group | | [subnet\_group\_vpc\_id](#output\_subnet\_group\_vpc\_id) | The VPC in which the subnet group exists | | [users](#output\_users) | Map of attributes for the users created | - + ## License diff --git a/examples/complete/README.md b/examples/complete/README.md index 31d07d1..c3f2fc5 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -20,7 +20,7 @@ $ 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 | @@ -75,6 +75,6 @@ No inputs. | [subnet\_group\_id](#output\_subnet\_group\_id) | Name of the subnet group | | [subnet\_group\_vpc\_id](#output\_subnet\_group\_vpc\_id) | The VPC in which the subnet group exists | | [users](#output\_users) | Map of attributes for the users created | - + Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-memory-db/blob/master/LICENSE). From ca8922385e93a7fce0fecfbb66b8f6e368a8d266 Mon Sep 17 00:00:00 2001 From: Melissa Greenbaum <69476188+magreenbaum@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:27:40 -0500 Subject: [PATCH 2/3] feat: Support `engine` argument and `valkey` (#10) --- README.md | 8 +- examples/complete/README.md | 4 +- examples/complete/versions.tf | 2 +- examples/valkey/README.md | 80 +++++++++++++++++++ examples/valkey/main.tf | 146 ++++++++++++++++++++++++++++++++++ examples/valkey/outputs.tf | 95 ++++++++++++++++++++++ examples/valkey/variables.tf | 0 examples/valkey/versions.tf | 15 ++++ main.tf | 1 + variables.tf | 8 +- versions.tf | 2 +- 11 files changed, 353 insertions(+), 8 deletions(-) create mode 100644 examples/valkey/README.md create mode 100644 examples/valkey/main.tf create mode 100644 examples/valkey/outputs.tf create mode 100644 examples/valkey/variables.tf create mode 100644 examples/valkey/versions.tf diff --git a/README.md b/README.md index 0332e8b..1d5d4e5 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ module "memory_db" { Examples codified under the [`examples`](https://github.com/terraform-aws-modules/terraform-aws-memory-db/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! - [Complete](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples/complete) +- [Valkey](https://github.com/terraform-aws-modules/terraform-aws-memory-db/tree/master/examples/valkey) ## Requirements @@ -118,13 +119,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | >= 5.47 | +| [aws](#requirement\_aws) | >= 5.78 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.47 | +| [aws](#provider\_aws) | >= 5.78 | ## Modules @@ -156,7 +157,8 @@ No modules. | [create\_users](#input\_create\_users) | Determines whether to create users specified | `bool` | `true` | no | | [data\_tiering](#input\_data\_tiering) | Must be set to `true` when using a data tiering node type | `bool` | `null` | no | | [description](#input\_description) | Description for the cluster. Defaults to `Managed by Terraform` | `string` | `null` | no | -| [engine\_version](#input\_engine\_version) | Version number of the Redis engine to be used for the cluster. Downgrades are not supported | `string` | `null` | no | +| [engine](#input\_engine) | The engine that will run on your nodes. Supported values are redis and valkey | `string` | `null` | no | +| [engine\_version](#input\_engine\_version) | Version number of the engine to be used for the cluster. Downgrades are not supported | `string` | `null` | no | | [final\_snapshot\_name](#input\_final\_snapshot\_name) | Name of the final cluster snapshot to be created when this resource is deleted. If omitted, no final snapshot will be made | `string` | `null` | no | | [kms\_key\_arn](#input\_kms\_key\_arn) | ARN of the KMS key used to encrypt the cluster at rest | `string` | `null` | no | | [maintenance\_window](#input\_maintenance\_window) | Specifies the weekly time range during which maintenance on the cluster is performed. It is specified as a range in the format `ddd:hh24:mi-ddd:hh24:mi` | `string` | `null` | no | diff --git a/examples/complete/README.md b/examples/complete/README.md index c3f2fc5..a3e9abe 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -26,14 +26,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.47 | +| [aws](#requirement\_aws) | >= 5.78 | | [random](#requirement\_random) | >= 3.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.47 | +| [aws](#provider\_aws) | >= 5.78 | | [random](#provider\_random) | >= 3.0 | ## Modules diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 5e9aae4..428fd69 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.47" + version = ">= 5.78" } random = { source = "hashicorp/random" diff --git a/examples/valkey/README.md b/examples/valkey/README.md new file mode 100644 index 0000000..bbd951b --- /dev/null +++ b/examples/valkey/README.md @@ -0,0 +1,80 @@ +# Valkey AWS MemoryDB Example + +Configuration in this directory creates: + +- AWS MemoryDB cluster +- AWS MemoryDB users +- AWS MemoryDB ACL +- AWS MemoryDB subnet group +- AWS MemoryDB 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.78 | +| [random](#requirement\_random) | >= 3.0 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | >= 5.78 | +| [random](#provider\_random) | >= 3.0 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [memory\_db](#module\_memory\_db) | ../.. | n/a | +| [memory\_db\_disabled](#module\_memory\_db\_disabled) | ../.. | n/a | +| [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | + +## Resources + +| Name | Type | +|------|------| +| [aws_sns_topic.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource | +| [random_password.password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource | + +## Inputs + +No inputs. + +## Outputs + +| Name | Description | +|------|-------------| +| [acl\_arn](#output\_acl\_arn) | The ARN of the ACL | +| [acl\_id](#output\_acl\_id) | Name of the ACL | +| [acl\_minimum\_engine\_version](#output\_acl\_minimum\_engine\_version) | The minimum engine version supported by the ACL | +| [cluster\_arn](#output\_cluster\_arn) | The ARN of the cluster | +| [cluster\_endpoint\_address](#output\_cluster\_endpoint\_address) | DNS hostname of the cluster configuration endpoint | +| [cluster\_endpoint\_port](#output\_cluster\_endpoint\_port) | Port number that the cluster configuration endpoint is listening on | +| [cluster\_engine\_patch\_version](#output\_cluster\_engine\_patch\_version) | Patch version number of the Redis engine used by the cluster | +| [cluster\_id](#output\_cluster\_id) | Cluster name | +| [cluster\_shards](#output\_cluster\_shards) | Set of shards in this cluster | +| [parameter\_group\_arn](#output\_parameter\_group\_arn) | The ARN of the parameter group | +| [parameter\_group\_id](#output\_parameter\_group\_id) | Name of the parameter group | +| [subnet\_group\_arn](#output\_subnet\_group\_arn) | ARN of the subnet group | +| [subnet\_group\_id](#output\_subnet\_group\_id) | Name of the subnet group | +| [subnet\_group\_vpc\_id](#output\_subnet\_group\_vpc\_id) | The VPC in which the subnet group exists | +| [users](#output\_users) | Map of attributes for the users created | + + +Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-memory-db/blob/master/LICENSE). diff --git a/examples/valkey/main.tf b/examples/valkey/main.tf new file mode 100644 index 0000000..effe11b --- /dev/null +++ b/examples/valkey/main.tf @@ -0,0 +1,146 @@ +provider "aws" { + region = local.region +} + +locals { + region = "us-east-1" + name = "memorydb-ex-${replace(basename(path.cwd), "_", "-")}" + + tags = { + Example = local.name + Environment = "dev" + } +} + +################################################################################ +# MemoryDB Module +################################################################################ + +module "memory_db_disabled" { + source = "../.." + + name = "${local.name}-disabled" + create = false +} + +module "memory_db" { + source = "../.." + + # Cluster + name = local.name + description = "Example MemoryDB cluster" + + engine = "valkey" + engine_version = "7.2" + auto_minor_version_upgrade = true + node_type = "db.r6gd.xlarge" + num_shards = 2 + num_replicas_per_shard = 2 + data_tiering = true + + tls_enabled = true + security_group_ids = [module.security_group.security_group_id] + maintenance_window = "sun:23:00-mon:01:30" + sns_topic_arn = aws_sns_topic.example.arn + snapshot_retention_limit = 7 + snapshot_window = "05:00-09:00" + + # Users + users = { + admin = { + user_name = "admin-user" + access_string = "on ~* &* +@all" + type = "iam" + tags = { user = "admin" } + } + readonly = { + user_name = "readonly-user" + access_string = "on ~* &* -@all +@read" + passwords = [random_password.password.result] + tags = { user = "readonly" } + } + } + + # ACL + acl_name = "${local.name}-acl" + acl_tags = { acl = "custom" } + + # Parameter group + parameter_group_name = "${local.name}-param-group" + parameter_group_description = "Example Valkey MemoryDB parameter group" + parameter_group_family = "memorydb_valkey7" + parameter_group_parameters = [ + { + name = "activedefrag" + value = "yes" + } + ] + parameter_group_tags = { + parameter_group = "custom" + } + + # Subnet group + subnet_group_name = "${local.name}-subnet-group" + subnet_group_description = "Example Valkey MemoryDB subnet group" + subnet_ids = module.vpc.database_subnets + subnet_group_tags = { + subnet_group = "custom" + } + + tags = local.tags +} + +################################################################################ +# Supporting Resources +################################################################################ + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 5.0" + + name = local.name + cidr = "10.98.0.0/18" + + azs = ["${local.region}a", "${local.region}b", "${local.region}d"] # Caution: check which zones are available + private_subnets = ["10.98.0.0/24", "10.98.1.0/24", "10.98.2.0/24"] + database_subnets = ["10.98.3.0/24", "10.98.4.0/24", "10.98.5.0/24"] + + create_database_subnet_group = true + enable_nat_gateway = false + + manage_default_security_group = true + default_security_group_ingress = [] + default_security_group_egress = [] + + tags = local.tags +} + +module "security_group" { + source = "terraform-aws-modules/security-group/aws" + version = "~> 4.0" + + name = local.name + description = "Security group for ${local.name}" + vpc_id = module.vpc.vpc_id + + ingress_cidr_blocks = module.vpc.private_subnets_cidr_blocks + ingress_rules = ["redis-tcp"] + + egress_cidr_blocks = [module.vpc.vpc_cidr_block] + egress_rules = ["all-all"] + + tags = local.tags +} + +resource "aws_sns_topic" "example" { + name = local.name + kms_master_key_id = "alias/aws/sns" + + tags = local.tags +} + +resource "random_password" "password" { + length = 16 + special = true + override_special = "_%@" +} diff --git a/examples/valkey/outputs.tf b/examples/valkey/outputs.tf new file mode 100644 index 0000000..ee65b87 --- /dev/null +++ b/examples/valkey/outputs.tf @@ -0,0 +1,95 @@ +################################################################################ +# Cluster +################################################################################ + +output "cluster_id" { + description = "Cluster name" + value = module.memory_db.cluster_id +} + +output "cluster_arn" { + description = "The ARN of the cluster" + value = module.memory_db.cluster_arn +} + +output "cluster_endpoint_address" { + description = "DNS hostname of the cluster configuration endpoint" + value = module.memory_db.cluster_endpoint_address +} + +output "cluster_endpoint_port" { + description = "Port number that the cluster configuration endpoint is listening on" + value = module.memory_db.cluster_endpoint_port +} + +output "cluster_engine_patch_version" { + description = "Patch version number of the Redis engine used by the cluster" + value = module.memory_db.cluster_engine_patch_version +} + +output "cluster_shards" { + description = "Set of shards in this cluster" + value = module.memory_db.cluster_shards +} + +################################################################################ +# User(s) +################################################################################ + +output "users" { + description = "Map of attributes for the users created" + value = module.memory_db.users + sensitive = true +} + +################################################################################ +# ACL +################################################################################ + +output "acl_id" { + description = "Name of the ACL" + value = module.memory_db.acl_id +} + +output "acl_arn" { + description = "The ARN of the ACL" + value = module.memory_db.acl_arn +} + +output "acl_minimum_engine_version" { + description = "The minimum engine version supported by the ACL" + value = module.memory_db.acl_minimum_engine_version +} + +################################################################################ +# Parameter Group +################################################################################ + +output "parameter_group_id" { + description = "Name of the parameter group" + value = module.memory_db.parameter_group_id +} + +output "parameter_group_arn" { + description = "The ARN of the parameter group" + value = module.memory_db.parameter_group_arn +} + +################################################################################ +# Subnet Group +################################################################################ + +output "subnet_group_id" { + description = "Name of the subnet group" + value = module.memory_db.subnet_group_id +} + +output "subnet_group_arn" { + description = "ARN of the subnet group" + value = module.memory_db.subnet_group_arn +} + +output "subnet_group_vpc_id" { + description = "The VPC in which the subnet group exists" + value = module.memory_db.subnet_group_vpc_id +} diff --git a/examples/valkey/variables.tf b/examples/valkey/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/valkey/versions.tf b/examples/valkey/versions.tf new file mode 100644 index 0000000..428fd69 --- /dev/null +++ b/examples/valkey/versions.tf @@ -0,0 +1,15 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.78" + } + random = { + source = "hashicorp/random" + version = ">= 3.0" + } + + } +} diff --git a/main.tf b/main.tf index e0f935e..2c655f1 100644 --- a/main.tf +++ b/main.tf @@ -20,6 +20,7 @@ resource "aws_memorydb_cluster" "this" { name_prefix = var.use_name_prefix ? "${var.name}-" : null description = var.description + engine = var.engine engine_version = var.engine_version auto_minor_version_upgrade = var.auto_minor_version_upgrade port = var.port diff --git a/variables.tf b/variables.tf index aec277f..56ce4d0 100644 --- a/variables.tf +++ b/variables.tf @@ -32,8 +32,14 @@ variable "description" { default = null } +variable "engine" { + description = "The engine that will run on your nodes. Supported values are redis and valkey" + type = string + default = null +} + variable "engine_version" { - description = "Version number of the Redis engine to be used for the cluster. Downgrades are not supported" + description = "Version number of the engine to be used for the cluster. Downgrades are not supported" type = string default = null } diff --git a/versions.tf b/versions.tf index 407a955..99c199f 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 5.47" + version = ">= 5.78" } } } From 42be407604c9ec4452f1f5bcc32a142ce9ab75a5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 30 Nov 2024 18:28:07 +0000 Subject: [PATCH 3/3] chore(release): version 2.2.0 [skip ci] ## [2.2.0](https://github.com/terraform-aws-modules/terraform-aws-memory-db/compare/v2.1.0...v2.2.0) (2024-11-30) ### Features * Support `engine` argument and `valkey` ([#10](https://github.com/terraform-aws-modules/terraform-aws-memory-db/issues/10)) ([ca89223](https://github.com/terraform-aws-modules/terraform-aws-memory-db/commit/ca8922385e93a7fce0fecfbb66b8f6e368a8d266)) ### Bug Fixes * Update CI workflow versions to latest ([#9](https://github.com/terraform-aws-modules/terraform-aws-memory-db/issues/9)) ([c8540d6](https://github.com/terraform-aws-modules/terraform-aws-memory-db/commit/c8540d6cea45cd7cfb61793838c097f14c64c0fd)) --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cc666c..50066c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. +## [2.2.0](https://github.com/terraform-aws-modules/terraform-aws-memory-db/compare/v2.1.0...v2.2.0) (2024-11-30) + + +### Features + +* Support `engine` argument and `valkey` ([#10](https://github.com/terraform-aws-modules/terraform-aws-memory-db/issues/10)) ([ca89223](https://github.com/terraform-aws-modules/terraform-aws-memory-db/commit/ca8922385e93a7fce0fecfbb66b8f6e368a8d266)) + + +### Bug Fixes + +* Update CI workflow versions to latest ([#9](https://github.com/terraform-aws-modules/terraform-aws-memory-db/issues/9)) ([c8540d6](https://github.com/terraform-aws-modules/terraform-aws-memory-db/commit/c8540d6cea45cd7cfb61793838c097f14c64c0fd)) + ## [2.1.0](https://github.com/terraform-aws-modules/terraform-aws-memory-db/compare/v2.0.1...v2.1.0) (2024-05-07)