Coder Social home page Coder Social logo

terraform-aws-modules / terraform-aws-memory-db Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 18.0 27 KB

Terraform module to create AWS MemoryDB resources πŸ‡ΊπŸ‡¦

Home Page: https://registry.terraform.io/modules/terraform-aws-modules/memory-db/aws

License: Apache License 2.0

HCL 100.00%
aws memory-database aws-memory-db terraform terraform-module

terraform-aws-memory-db's Introduction

AWS MemoryDB Terraform module

Terraform module which creates AWS MemoryDB resources.

Usage

See examples directory for working examples to reference:

module "memory_db" {
  source = "terraform-aws-modules/memory-db/aws"

  # Cluster
  name        = "example"
  description = "Example MemoryDB cluster"

  engine_version             = "6.2"
  auto_minor_version_upgrade = true
  node_type                  = "db.t4g.small"
  num_shards                 = 2
  num_replicas_per_shard     = 2

  tls_enabled              = true
  security_group_ids       = ["sg-12345678"]
  maintenance_window       = "sun:23:00-mon:01:30"
  sns_topic_arn            = "arn:aws:sns:us-east-1:012345678910:example-topic"
  snapshot_retention_limit = 7
  snapshot_window          = "05:00-09:00"

  # Users
  users = {
    admin = {
      user_name     = "admin-user"
      access_string = "on ~* &* +@all"
      passwords     = ["YouShouldPickAStrongSecurePassword987!"]
      tags          = { User = "admin" }
    }
    readonly = {
      user_name     = "readonly-user"
      access_string = "on ~* &* -@all +@read"
      passwords     = ["YouShouldPickAStrongSecurePassword123!"]
      tags          = { User = "readonly" }
    }
  }

  # ACL
  acl_name = "example-acl"
  acl_tags = { Acl = "custom" }

  # Parameter group
  parameter_group_name        = "example-param-group"
  parameter_group_description = "Example MemoryDB parameter group"
  parameter_group_family      = "memorydb_redis6"
  parameter_group_parameters = [
    {
      name  = "activedefrag"
      value = "yes"
    }
  ]
  parameter_group_tags = {
    ParameterGroup = "custom"
  }

  # Subnet group
  subnet_group_name        = "example-subnet-group"
  subnet_group_description = "Example MemoryDB subnet group"
  subnet_ids               = ["subnet-1fe3d837", "subnet-129d66ab", "subnet-1211eef5"]
  subnet_group_tags = {
    SubnetGroup = "custom"
  }

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

Conditional Creation

The following values are provided to toggle on/off creation of the associated resources as desired:

module "memory_db" {
  source = "terraform-aws-modules/memory-db/aws"

  # Disable creation of cluster and all resources
  create = false

  # Disable creation of users
  create_users = false

  # Disable creation of ACL - an ACL will need to be provided
  create_acl = false
  acl_name   = "existing_acl"

  # Disable creation of parameter group - a parameter group will need to be provided
  create_parameter_group = false
  parameter_group_name   = "existing_parameter_group"

  # Disable creation of subnet group - a subnet group will need to be provided
  create_subnet_group = false
  subnet_group_name   = "existing_subnet_group"

  # ... omitted
}

Examples

Examples codified under the 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!

Requirements

Name Version
terraform >= 1.0
aws >= 5.47

Providers

Name Version
aws >= 5.47

Modules

No modules.

Resources

Name Type
aws_memorydb_acl.this resource
aws_memorydb_cluster.this resource
aws_memorydb_parameter_group.this resource
aws_memorydb_subnet_group.this resource
aws_memorydb_user.this resource

Inputs

Name Description Type Default Required
acl_name Name of ACL to be created if create_acl is true, otherwise its the name of an existing ACL to use if create_acl is false string null no
acl_tags Additional tags for the ACL created map(string) {} no
acl_use_name_prefix Determines whether acl_name is used as a prefix bool false no
acl_user_names List of externally created user names to associate with the ACL list(string) [] no
auto_minor_version_upgrade When set to true, the cluster will automatically receive minor engine version upgrades after launch. Defaults to true bool null no
create Determines whether resources will be created - affects all resources bool true no
create_acl Determines whether to create ACL specified bool true no
create_parameter_group Determines whether to create parameter group specified bool true no
create_subnet_group Determines whether to create subnet group specified bool true no
create_users Determines whether to create users specified bool true no
data_tiering Must be set to true when using a data tiering node type bool null no
description Description for the cluster. Defaults to Managed by Terraform string null no
engine_version Version number of the Redis engine to be used for the cluster. Downgrades are not supported string null no
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 ARN of the KMS key used to encrypt the cluster at rest string null no
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
name Cluster name - also default name used on all resources if more specific resource names are not provided string "" no
node_type The compute and memory capacity of the nodes in the cluster. See AWS documentation on supported node types as well as vertical scaling string null no
num_replicas_per_shard The number of replicas to apply to each shard, up to a maximum of 5. Defaults to 1 (i.e. 2 nodes per shard) number null no
num_shards The number of shards in the cluster. Defaults to 1 number null no
parameter_group_description Description for the parameter group. Defaults to Managed by Terraform string null no
parameter_group_family The engine version that the parameter group can be used with string null no
parameter_group_name Name of parameter group to be created if create_parameter_group is true, otherwise its the name of an existing parameter group to use if create_parameter_group is false string null no
parameter_group_parameters A list of parameter maps to apply list(map(string)) [] no
parameter_group_tags Additional tags for the parameter group created map(string) {} no
parameter_group_use_name_prefix Determines whether parameter_group_name is used as a prefix bool false no
port The port number on which each of the nodes accepts connections. Defaults to 6379 number null no
security_group_ids Set of VPC Security Group ID-s to associate with this cluster list(string) null no
snapshot_arns List of ARN-s that uniquely identify RDB snapshot files stored in S3. The snapshot files will be used to populate the new cluster list(string) null no
snapshot_name The name of a snapshot from which to restore data into the new cluster string null no
snapshot_retention_limit The number of days for which MemoryDB retains automatic snapshots before deleting them. When set to 0, automatic backups are disabled. Defaults to 0 number null no
snapshot_window The daily time range (in UTC) during which MemoryDB begins taking a daily snapshot of your shard. Example: 05:00-09:00 string null no
sns_topic_arn ARN of the SNS topic to which cluster notifications are sent string null no
subnet_group_description Description for the subnet group. Defaults to Managed by Terraform string null no
subnet_group_name Name of subnet group to be created if create_subnet_group is true, otherwise its the name of an existing subnet group to use if create_subnet_group is false string null no
subnet_group_tags Additional tags for the subnet group created map(string) {} no
subnet_group_use_name_prefix Determines whether subnet_group_name is used as a prefix bool false no
subnet_ids Set of VPC Subnet ID-s for the subnet group. At least one subnet must be provided list(string) [] no
tags A map of tags to use on all resources map(string) {} no
tls_enabled A flag to enable in-transit encryption on the cluster. When set to false, the acl_name must be open-access. Defaults to true bool null no
use_name_prefix Determines whether name is used as a prefix for the cluster bool false no
users A map of user definitions (maps) to be created any {} no

Outputs

Name Description
acl_arn The ARN of the ACL
acl_id Name of the ACL
acl_minimum_engine_version The minimum engine version supported by the ACL
cluster_arn The ARN of the cluster
cluster_endpoint_address DNS hostname of the cluster configuration endpoint
cluster_endpoint_port Port number that the cluster configuration endpoint is listening on
cluster_engine_patch_version Patch version number of the Redis engine used by the cluster
cluster_id Cluster name
cluster_shards Set of shards in this cluster
parameter_group_arn The ARN of the parameter group
parameter_group_id Name of the parameter group
subnet_group_arn ARN of the subnet group
subnet_group_id Name of the subnet group
subnet_group_vpc_id The VPC in which the subnet group exists
users Map of attributes for the users created

License

Apache-2.0 Licensed. See LICENSE.

terraform-aws-memory-db's People

Contributors

bryantbiggs avatar dev-slatto avatar magreenbaum avatar semantic-release-bot avatar typat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-aws-memory-db's Issues

vector search enabled MemoryDB cluster via terraform module

via aws-cli we can create the cluster with vector search enabeld by passing the parameter group default.memorydb-redis7.search.preview, as stated in:

To create a vector search enabled MemoryDB cluster, you can use the MemoryDB [create-cluster](https://docs.aws.amazon.com/cli/latest/reference/memorydb/create-cluster.html) command by passing an immutable parameter group default.memorydb-redis7.search.preview to enable the preview mode for vector search capabilities.

However, when I do that via terraform:


module "memory_db" {
  source = "terraform-aws-modules/memory-db/aws"


  engine_version            = "7.1"
  node_type                    = "db.r7g.2xlarge"
  num_shards                 = 1
  
  # Parameter group
  create_parameter_group = false
  parameter_group_family = "default.memorydb-redis7.search.preview"
 (...)
 (...)
}

it's not enabled.
I've confirmed it:

-ERR Command not enabled, instance needs to be configured for Public Preview for Vector Similarity Search

terraform-aws-memory-db: include lifecycle block to aws_memorydb_cluster to avoid possible downtimes

Is your request related to a new offering from AWS?

Is this functionality available in the AWS provider for Terraform? See CHANGELOG.md, too.

  • No πŸ›‘: please wait to file a request until the functionality is avaialble in the AWS provider
  • Yes βœ…: please list the AWS provider version which introduced this functionality

Is your request related to a problem? Please describe.

I am using the terraform-aws-modules/terraform-aws-memory-db module but I am seeing creating and destroying of the aws_memorydb_cluster, simultaneously. This might cause an abrupt breaking change for an application that relies on the MemoryDB cluster and could lead to app crashes, possibly longer downtimes.

Describe the solution you'd like.

It would be great if had a lifecycle block (as shown below) on the aws_memorydb_cluster resource as well so we can reduce the amount of downtime for the application. We would still need to pass the newer cluster_endpoint_address downstream to dependent compute resources, like Lambda, EC2 and so on.

lifecycle {
  create_before_destroy = true
}

The proposed change could reduce the amount of time for the application to come back online.

Describe alternatives you've considered.

I would love to throw a lifecycle block on the module reference code in Terraform but lifecycle is not supported on modules yet. Refer hashicorp/terraform#27360.

I am willing to fork the repository and make the changes and submit a PR, if the changes/feature request makes sense.

Thank you for your contributions to the Terraform community!

Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.