### Terraform Initialization, Plan, and Apply Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/examples/redis-cluster-mode/README.md Commands to initialize, plan, and apply the Terraform configuration for the ElastiCache example. Ensure you run these in the directory containing the configuration. ```bash $ terraform init $ terraform plan $ terraform apply ``` -------------------------------- ### Terragrunt Configuration for Serverless Cache Wrapper Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/serverless-cache/README.md Example Terragrunt configuration file (`terragrunt.hcl`) demonstrating how to use the serverless cache module wrapper. It specifies the source and input variables, including default values and items to be managed. ```hcl terraform { source = "tfr:///terraform-aws-modules/elasticache/aws//wrappers/serverless-cache" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-elasticache.git//wrappers/serverless-cache?ref=master" } inputs = { defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Terragrunt Configuration for User Group Wrapper Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/user-group/README.md Example `terragrunt.hcl` file demonstrating how to use the user-group wrapper module. It specifies the source and provides default and item-specific inputs for managing multiple Elasticache user groups. ```hcl terraform { source = "tfr:///terraform-aws-modules/elasticache/aws//wrappers/user-group" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-elasticache.git//wrappers/user-group?ref=master" } inputs = { defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Memcached Cluster Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Example of creating a Memcached ElastiCache cluster. Ensure the correct parameter group family is specified for Memcached. ```hcl module "elasticache" { source = "terraform-aws-modules/elasticache/aws" cluster_id = "example-memcached" create_cluster = true create_replication_group = false engine = "memcached" engine_version = "1.6.17" node_type = "cache.t4g.small" num_cache_nodes = 2 az_mode = "cross-az" 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_ids = module.vpc.private_subnets # Parameter Group create_parameter_group = true parameter_group_family = "memcached1.6" parameters = [ { name = "idle_timeout" value = 60 } ] tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Terraform Configuration for Serverless Cache Wrapper Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/serverless-cache/README.md Example Terraform configuration using the serverless cache module wrapper. This snippet shows how to define the module source and input variables, including defaults and specific items. ```hcl module "wrapper" { source = "terraform-aws-modules/elasticache/aws//wrappers/serverless-cache" defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Terragrunt Example for Managing Multiple S3 Buckets Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/user-group/README.md Illustrates using a Terragrunt wrapper for the S3 bucket module to manage multiple buckets within a single configuration. It sets default configurations and defines individual bucket settings. ```hcl terraform { source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" } inputs = { defaults = { force_destroy = true attach_elb_log_delivery_policy = true attach_lb_log_delivery_policy = true attach_deny_insecure_transport_policy = true attach_require_latest_tls_policy = true } items = { bucket1 = { bucket = "my-random-bucket-1" } bucket2 = { bucket = "my-random-bucket-2" tags = { Secure = "probably" } } } } ``` -------------------------------- ### Redis Cluster Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Example for creating a Redis ElastiCache cluster. Specify the appropriate engine version and parameter group family for Redis. ```hcl module "elasticache" { source = "terraform-aws-modules/elasticache/aws" cluster_id = "example-redis" create_cluster = true create_replication_group = false engine_version = "7.1" node_type = "cache.t4g.small" 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_ids = module.vpc.private_subnets # Parameter Group create_parameter_group = true parameter_group_family = "redis7" parameters = [ { name = "latency-tracking" value = "yes" } ] tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Terragrunt Configuration for Multiple S3 Buckets Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/serverless-cache/README.md An example Terragrunt configuration file for managing multiple S3 buckets using a wrapper module. It demonstrates setting default bucket configurations and defining individual bucket properties. ```hcl terraform { source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" } inputs = { defaults = { force_destroy = true attach_elb_log_delivery_policy = true attach_lb_log_delivery_policy = true attach_deny_insecure_transport_policy = true attach_require_latest_tls_policy = true } items = { bucket1 = { bucket = "my-random-bucket-1" } bucket2 = { bucket = "my-random-bucket-2" tags = { Secure = "probably" } } } } ``` -------------------------------- ### Redis Cluster Mode Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Example for creating a Redis ElastiCache cluster with cluster mode enabled. Configure `num_node_groups`, `replicas_per_node_group`, and failover settings. ```hcl module "elasticache" { source = "terraform-aws-modules/elasticache/aws" replication_group_id = "example-redis-cluster" # Cluster mode cluster_mode_enabled = true num_node_groups = 2 replicas_per_node_group = 3 automatic_failover_enabled = true multi_az_enabled = true 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_ids = module.vpc.private_subnets # Parameter Group create_parameter_group = true parameter_group_family = "redis7" parameters = [ { name = "latency-tracking" value = "yes" } ] tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Terraform Configuration for User Group Wrapper Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/user-group/README.md Example Terraform configuration block for using the user-group wrapper module. It shows how to set the module source and define default and item-specific inputs for managing multiple Elasticache user groups. ```hcl module "wrapper" { source = "terraform-aws-modules/elasticache/aws//wrappers/user-group" defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Terraform Initialization, Plan, and Apply Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/examples/valkey-replication-group/README.md Standard commands to initialize, plan, and apply Terraform configurations. Ensure you have the AWS provider configured. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Create Valkey Replication Group Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Configure a Valkey replication group with specified engine version and node type. Enable transit encryption and set an authentication token. Define subnet group and parameter group settings, including custom parameters. ```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 } ``` -------------------------------- ### Create Serverless Cache Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Deploy a serverless cache with defined usage limits for data storage and ECPU per second. Configure daily snapshot times, encryption using a KMS key, and associate security groups and subnets. ```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 } ``` -------------------------------- ### Basic Serverless Cache Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/modules/serverless-cache/README.md Configure a basic ElastiCache serverless cache with Redis engine, name, usage limits, and security group integration. Ensure necessary KMS key and VPC subnets are defined. ```hcl module "elasticache_serverless_cache" { 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 tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Basic ElastiCache User Group Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/modules/user-group/README.md This snippet demonstrates a basic configuration for creating an ElastiCache user group with a default user and two custom users. One custom user uses IAM authentication, while the other uses password authentication with multiple passwords. ```hcl module "elasticache_user_group" { source = "terraform-aws-modules/elasticache/aws//modules/user-group" user_group_id = "example" default_user = { user_id = "defaultExample" passwords = ["password123456789"] } users = { moe = { access_string = "on ~* +@all" passwords = ["password123456789"] } larry = { access_string = "on ~* +@all" authentication_mode = { type = "iam" } } curly = { access_string = "on ~* +@all" authentication_mode = { type = "password" passwords = ["password123456789", "password987654321"] } } } tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Create Redis Replication Group Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Use this snippet to create a Redis replication group. Ensure transit encryption is enabled and provide a secure authentication token. Configure maintenance windows and specify immediate application of changes. ```hcl module "elasticache" { source = "terraform-aws-modules/elasticache/aws" replication_group_id = "example-redis-replication-group" engine_version = "7.1" 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_ids = module.vpc.private_subnets # Parameter Group create_parameter_group = true parameter_group_family = "redis7" parameters = [ { name = "latency-tracking" value = "yes" } ] tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Terraform Usage for Elasticache Wrappers Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/README.md Use Terraform to manage multiple instances of the Elasticache module. This pattern is beneficial for organizing and managing module configurations. ```hcl module "wrapper" { source = "terraform-aws-modules/elasticache/aws//wrappers" defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Redis Global Replication Group Primary Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Configuration for the primary ElastiCache Redis cluster in a global replication group. This sets up the primary region's resources. ```hcl module "elasticache_primary" { source = "terraform-aws-modules/elasticache/aws" replication_group_id = "example-redis-global-replication-group" create_primary_global_replication_group = true engine_version = "7.1" node_type = "cache.r7g.large" # 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_ids = module.vpc.private_subnets # Parameter Group create_parameter_group = true parameter_group_family = "redis7" tags = { Terraform = "true" Environment = "dev" } } ``` -------------------------------- ### Terragrunt Usage for Elasticache Wrappers Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/wrappers/README.md Configure Terragrunt to manage multiple instances of the Elasticache module. This is useful when native Terraform for_each is not suitable. ```hcl terraform { source = "tfr:///terraform-aws-modules/elasticache/aws//wrappers" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-elasticache.git//wrappers?ref=master" } inputs = { defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### Redis Global Replication Group Secondary Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-elasticache/blob/master/README.md Configuration for a secondary ElastiCache Redis cluster in a global replication group. This requires the `global_replication_group_id` from the primary. ```hcl module "elasticache_secondary" { source = "terraform-aws-modules/elasticache/aws" providers = { aws = aws.other_region } replication_group_id = "example-redis-global-replication-group" global_replication_group_id = module.elasticache_primary.global_replication_group_id # 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_ids = module.vpc.private_subnets tags = { Terraform = "true" Environment = "dev" } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.