terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

Failing to upgrade Redis 3.2.4 to 6.2 - CacheParameterGroupName invalid

Open c0debreaker opened this issue 3 years ago • 3 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

0.13.5

Affected Resource(s)

  • aws_elasticache_replication_group

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

provider "aws" {
  profile = var.account
  region  = "us-east-1"

  allowed_account_ids = [
    var.account_number,
  ]

  assume_role {
    role_arn     = var.atlantis_assume_role_arn
    session_name = "${var.atlantis_user}-${var.atlantis_repo_owner}-${var.atlantis_repo_name}-${var.atlantis_pull_num}"
  }
}

provider "aws" {
  alias  = "stage_zone"
  region = "us-east-1"

  assume_role {
    role_arn     = var.stage_atlantis_assume_role_arn
    session_name = "stage_cross_cx"
  }
}

provider "template" {}

terraform {
  required_version = ">= 0.13.5"
  required_providers {
    aws      = ">= 3.0"
    template = "~> 2.1"
  }

  backend "s3" {
    bucket         = "*******-devops-terraform-state"
    key            = "terraform/dev-vpc/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "*******-devops-terraform-state-lock"
    profile        = "build"
  }
}


-----------------------
and in our elasticache.tf
-----------------------
resource "aws_elasticache_replication_group" "pimcore" {
  automatic_failover_enabled    = true
  engine                        = "redis"
  replication_group_description = "pimcore"
  replication_group_id          = "pimcore"
  maintenance_window            = "sun:09:00-sun:10:00"
  multi_az_enabled              = true
  node_type                     = "cache.t2.small"
  num_cache_clusters            = 4
  parameter_group_name          = "default.redis6.x"
  port                          = 6379
  security_group_ids = [
    aws_security_group.apps_all.id,
    data.aws_security_group.default.id,
    module.security-enabled.enabled_access_apps_all_id,
  ]
  snapshot_retention_limit = 1
  snapshot_window          = "06:30-07:30"
  subnet_group_name        = aws_elasticache_subnet_group.dev_cache_subnet.name
  tags = merge(
    {
      app_name  = "merchcenterproduct"
      app_group = "product"
    },
    local.common_tags,
  )
}

Debug Output

Panic Output

Expected Behavior

It should have upgraded redis 3.x to 6.x

Actual Behavior

I've tried so many different values in parameter_group_name and it always failed with the same error. The previous code before we upgraded it was parameter_group_name = "default.redis3.2.cluster.on".

I've tried the following with no luck default.redis6.2.cluster.on default.redis6.x.cluster.on default.redis6.x default.redis6.2

Steps to Reproduce

  1. terraform apply

output is

Error: error updating ElastiCache Replication Group (pimcore): InvalidParameterValue: The parameter CacheParameterGroupName is not a valid identifier. Identifiers must begin with a letter; must contain only ASCII letters, digits, and hyphens; and must not end with a hyphen or contain two consecutive hyphens.
	status code: 400, request id: 65868389-c26f-4510-8e13-b93ef4cb978a

  with aws_elasticache_replication_group.pimcore,
  on elasticache.tf line 100, in resource "aws_elasticache_replication_group" "pimcore":
 100: resource "aws_elasticache_replication_group" "pimcore" {

c0debreaker avatar Aug 25 '22 15:08 c0debreaker

Hey @c0debreaker 👋 Thank you for taking the time to raise this! In case whoever picks this up needs it, are you able to supply (redacted as necessary) debug logs as well?

justinretzolk avatar Aug 30 '22 21:08 justinretzolk

The error looks like you might have a missing or extra " somewhere, or some other character that messes up the syntax, and that field is the one catching it.

From a quick glance I can't tell from your copy pasted code, something might be missing.

madpipeline avatar Nov 23 '22 11:11 madpipeline

Probably a dupe of https://github.com/hashicorp/terraform-provider-aws/issues/21733, and I'm facing the same error when upgrading from 6.x to 7.0.

I guess that Terraform either tries to update the parameter group before upgrading, or tries to upgrade before changing the parameter group?

Presumably both have to be done as part of the same update API call, since the new parameter group is not valid with the old engine version and the new engine version is not valid with the old parameter group.

jbg avatar Nov 28 '22 04:11 jbg

I ran into this error on three out of four cluster upgrades that I just ran. Not sure why, but I found that if I viewed the list of parameter groups in the web UI and then re-ran the apply, it worked correctly. Perhaps the parameter groups are lazily created when queried?

rubysolo avatar Dec 28 '22 22:12 rubysolo