cloudposse / terraform-aws-elasticache-redis

Terraform module to provision an ElastiCache Redis Cluster
https://cloudposse.com/accelerate
Apache License 2.0
141 stars 244 forks source link

The parameter CacheSubnetGroupName must be provided and must not be blank. #89

Closed perryluopl closed 3 years ago

perryluopl commented 3 years ago

I use the module, https://github.com/cloudposse/terraform-aws-elasticache-redis to provision elasticache redis. Below are the errors when I run terraform apply. I have no clue of these errors.

Terraform version: v0.13.5

module.redis.aws_elasticache_parameter_group.default[0]: Creating...

module.redis.aws_elasticache_subnet_group.default[0]: Creating...

Error: Error creating CacheSubnetGroup: InvalidParameterValue: The parameter CacheSubnetGroupName must be provided and must not be blank. status code: 400, request id: a1ab57b1-fa23-491c-aa7b-a2d3804014c9

Error: Error creating Cache Parameter Group: InvalidParameterValue: The parameter CacheParameterGroupName must be provided and must not be blank. status code: 400, request id: 9abc80b6-bd3b-46fd-8b9e-9bf14d1913eb

module "redis" {
  source                     = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=tags/0.25.0"

  availability_zones               = var.azs
  vpc_id                           = module.vpc.vpc_id
  allowed_security_groups          = [data.aws_security_group.default.id]
  subnets                          = module.vpc.private_subnets
  cluster_size                     = var.redis_cluster_size #number_cache_clusters
  instance_type                    = var.redis_instance_type
  apply_immediately                = true
  automatic_failover_enabled       = false
  engine_version                   = var.engine_version
  family                           = var.family
  replication_group_id             = var.replication_group_id

  #at-rest encryption is to increase data security by encrypting on-disk data.
  at_rest_encryption_enabled       = var.at_rest_encryption_enabled

  #in-transit encryption protects data when it is moving from one location to another.
  transit_encryption_enabled       = var.transit_encryption_enabled

  cloudwatch_metric_alarms_enabled = var.cloudwatch_metric_alarms_enabled

  parameter = [
    {
      #Keyspace notifications send events for every operation affecting the Redis data space.
      name  = "notify-keyspace-events"
      value = "lK"
    }
  ]
  context = module.this.context
}
jamengual commented 3 years ago

have you try defining elasticache_subnet_group_name?

Gowiem commented 3 years ago

@perryluopl got your email. Please try out @jamengual's suggestion. If you can't get it to work through using that parameter then please join the SweetOps slack group and we'll help you triage there.

perryluopl commented 3 years ago

I added elasticache_subnet_group_name = var.elasticache_subnet_group_name. I still get the error. The error complains ParameterGroupName.

module.redis.aws_elasticache_parameter_group.default[0]: Creating...

Error: Error creating Cache Parameter Group: InvalidParameterValue: The parameter CacheParameterGroupName must be provided and must not be blank. status code: 400, request id: a00e1c93-7737-401a-95c1-ee569c58f950

module "redis" {
  source                     = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=tags/0.25.0"

  # data.aws_availability_zones.available defined in main_eks_vpc.tf
  availability_zones               = data.aws_availability_zones.available.names
  vpc_id                           = module.vpc.vpc_id
  allowed_security_groups          = [module.vpc.default_security_group_id]
  subnets                          = module.vpc.private_subnets
  cluster_size                     = var.redis_cluster_size #number_cache_clusters
  instance_type                    = var.redis_instance_type
  apply_immediately                = true
  automatic_failover_enabled       = true
  engine_version                   = var.redis_engine_version
  family                           = var.redis_family
  #enabled                          = var.enabled
  cluster_mode_enabled             = true
  enabled                          = true
  replication_group_id             = var.replication_group_id
  elasticache_subnet_group_name    = var.elasticache_subnet_group_name

  #at-rest encryption is to increase data security by encrypting on-disk data.
  at_rest_encryption_enabled       = var.at_rest_encryption_enabled

  #in-transit encryption protects data when it is moving from one location to another.
  transit_encryption_enabled       = var.transit_encryption_enabled

  cloudwatch_metric_alarms_enabled = var.cloudwatch_metric_alarms_enabled

  parameter = [
    {
      name  = "notify-keyspace-events"
      value = "lK"
    }
  ]

  context = module.this.context
}
jamengual commented 3 years ago

what version of aws provider are you running @perryluopl ?

perryluopl commented 3 years ago

Here is my code. The version >= 2.28.1. What version should I use? My terraform version is v0.13.5.

provider "aws" { version = ">= 2.28.1" region = var.region }

jamengual commented 3 years ago

You could try with 3.15.0 of the aws provider and see

On Sun., Nov. 8, 2020, 9:29 p.m. perryluopl, notifications@github.com wrote:

Here is my code. The version >= 2.28.1. What version should I use? My terraform version is v0.13.5.

provider "aws" { version = ">= 2.28.1" region = var.region }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudposse/terraform-aws-elasticache-redis/issues/89#issuecomment-723765417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERFCJYK7L2E7BKWE333SO544XANCNFSM4TNGLAWQ .

perryluopl commented 3 years ago

provider "aws" { version = "3.15.0" region = var.region }

I got error,

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints 3.15.0, >= 2.55.0, >= 2.49., >= 2.49., >= 2.49., >= 2.49., >= 2.49., >= 2.0., >= 2.0., >= 2.68., >= 2.49., >= 2.49., >= 2.49., >= 2.49., >= 2.49., >= 2.42., < 4.0., >= 2.42., < 4.0.*

perryluopl commented 3 years ago

I changed to, provider "aws" {

version = "3.15.0"

version = ">= 2.49" region = var.region } But, I still got, module.redis.aws_elasticache_parameter_group.default[0]: Creating...

Error: Error creating Cache Parameter Group: InvalidParameterValue: The parameter CacheParameterGroupName must be provided and must not be blank. status code: 400, request id: da290b99-2355-4b74-b3ad-c4094b1ee36d

Are you able to run the code at terraform-aws-elasticache-redis/examples/complete successfully?

jamengual commented 3 years ago

Every version we release runs terratest which create the infrastructure.

Have you ever deployed one successfully?

On Sun., Nov. 8, 2020, 9:43 p.m. perryluopl, notifications@github.com wrote:

I changed to, provider "aws" {

version = "3.15.0"

version = ">= 2.49" region = var.region } But, I still got, module.redis.aws_elasticache_parameter_group.default[0]: Creating...

Error: Error creating Cache Parameter Group: InvalidParameterValue: The parameter CacheParameterGroupName must be provided and must not be blank. status code: 400, request id: da290b99-2355-4b74-b3ad-c4094b1ee36d

Are you able to run the code at terraform-aws-elasticache-redis/examples/complete successfully?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudposse/terraform-aws-elasticache-redis/issues/89#issuecomment-723770676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERFBDKKLWPXEYLFQG53SO56PPANCNFSM4TNGLAWQ .

perryluopl commented 3 years ago

Every version we release runs terratest which create the infrastructure. Have you ever deployed one successfully? On Sun., Nov. 8, 2020, 9:43 p.m. perryluopl, @.***> wrote: I changed to, provider "aws" { #version = "3.15.0" version = ">= 2.49" region = var.region } But, I still got, module.redis.aws_elasticache_parameter_group.default[0]: Creating... Error: Error creating Cache Parameter Group: InvalidParameterValue: The parameter CacheParameterGroupName must be provided and must not be blank. status code: 400, request id: da290b99-2355-4b74-b3ad-c4094b1ee36d Are you able to run the code at terraform-aws-elasticache-redis/examples/complete successfully? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#89 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERFBDKKLWPXEYLFQG53SO56PPANCNFSM4TNGLAWQ .

No, I have not successfully deployed one yet.

perryluopl commented 3 years ago

Can anyone run the code I posted to reproduce the error?

jamengual commented 3 years ago

@perryluopl this recent run of the example shows this is working as expected:

https://github.com/cloudposse/actions/runs/1376256420?check_suite_focus=true

I used another PR and run all tests

jamengual commented 3 years ago

Join the slack channel so other people that have run elasticache can help you identify what is wrong

perryluopl commented 3 years ago

Found the problem. The default values of namespace/environment/stage/name in context.tf are null. That causes the problem. Set these values solved the problem.

hknoa1729 commented 1 year ago

Still the issue persist with latest release dated today with 0.45.0

mshiriv commented 1 year ago

Still the issue persist with latest release dated today with 0.50.0

stolarczyk commented 1 year ago

The issue persists in 0.52.0

vkryzh commented 1 year ago

Seems like you are forced to create :(

  context = {
    "additional_tag_map" : {},
    "attributes" : [],
    "delimiter" : null,
    "descriptor_formats" : {},
    "enabled" : true,
    "environment" : null,
    "id_length_limit" : null,
    "label_key_case" : null,
    "label_order" : [],
    "label_value_case" : null,
    "labels_as_tags" : ["unset"],
    "name" : "SOMETHING_HERE",
    "namespace" : null,
    "regex_replace_chars" : null,
    "stage" : null,
    "tags" : {},
    "tenant" : null
  }
kmkouokam commented 10 months ago

I think you should create a resource "aws_elasticache_subnet_group" subnet-group" {}, and add an entry subnet_group_name in your module "redis"

guhus commented 10 months ago

Same here, still happening with 0.53.0, context is forced to be used, a bit odd.