Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DBInstanceParameterGroupName in aws_rds_cluster #17357

Closed
rafaljanicki opened this issue Jan 29, 2021 · 7 comments · Fixed by #17111
Closed

Add support for DBInstanceParameterGroupName in aws_rds_cluster #17357

rafaljanicki opened this issue Jan 29, 2021 · 7 comments · Fixed by #17111
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service.
Milestone

Comments

@rafaljanicki
Copy link

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

Description

When upgrading a major version of Aurora RDS Cluster (MySQL in my case), AWS requires DBInstanceParameterGroupName parameter on the SDK call, otherwise it fails with InvalidParameterCombination: The current DB instance parameter group <xxx> is custom. You must explicitly specify a new DB instance parameter group, either default or custom, for the engine version upgrade. error

New or Affected Resource(s)

  • aws_rds_cluster
@rafaljanicki rafaljanicki added the enhancement Requests to existing resources that expand the functionality or scope. label Jan 29, 2021
@ghost ghost added the service/rds Issues and PRs that pertain to the rds service. label Jan 29, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 29, 2021
@gdepuille
Copy link
Contributor

gdepuille commented Apr 14, 2021

HI @rafaljanicki. I've made a PR to add this functionnality.
A custom version of the provider based on the 3.36.0 version is available on the terraform registry. The difference with the base version is only the content of the PR.

You can use it like this sample to test if it solved your problem.

terraform {
  required_version = ">= 0.14.0, < 0.15.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.36.0"
    }

    aws-sglk = {
      source  = "sogelink/aws"
      version = "3.36.0-sglk"
    }
  }
}

provider "aws" {
  region                  = "eu-west-1"
  shared_credentials_file = "~/.aws/credentials"
}

provider "aws-sglk" {
  region                  = "eu-west-1"
  shared_credentials_file = "~/.aws/credentials"
}

locals {
  name              = "test-aurora-custom"
  apply_immediately = true
  engine            = "aurora-postgresql"
  engine_version    = "12.4"
  family            = "${local.engine}${split(".", local.engine_version)[0]}"
}

data "aws_rds_orderable_db_instance" "test" {
  engine                     = aws_rds_cluster.test.engine
  engine_version             = aws_rds_cluster.test.engine_version
  preferred_instance_classes = ["db.t3.medium", "db.t3.large"]
}

resource "aws_rds_cluster" "test" {
  provider = aws-sglk

  allow_major_version_upgrade      = true
  apply_immediately                = local.apply_immediately
  cluster_identifier               = local.name
  engine                           = local.engine
  engine_version                   = local.engine_version
  master_password                  = "bestpassword4ever"
  master_username                  = "postgres"
  db_cluster_parameter_group_name  = aws_rds_cluster_parameter_group.cluster_parameters.name
  db_instance_parameter_group_name = aws_db_parameter_group.db_parameters.name
  skip_final_snapshot              = true
}

resource "aws_rds_cluster_instance" "test" {
  provider = aws-sglk

  cluster_identifier      = aws_rds_cluster.test.id
  apply_immediately       = local.apply_immediately
  engine                  = data.aws_rds_orderable_db_instance.test.engine
  engine_version          = data.aws_rds_orderable_db_instance.test.engine_version
  identifier              = local.name
  instance_class          = data.aws_rds_orderable_db_instance.test.instance_class
  db_parameter_group_name = aws_db_parameter_group.db_parameters.name
}

resource "aws_rds_cluster_parameter_group" "cluster_parameters" {
  name_prefix = "${local.name}-"
  family      = local.family

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_db_parameter_group" "db_parameters" {
  name_prefix = "${local.name}-"
  family      = local.family

  lifecycle {
    create_before_destroy = true
  }
}

@rafaljanicki
Copy link
Author

Thank you, you're awesome @gdepuille ! :-)

@svenedge
Copy link

svenedge commented Sep 6, 2021

If/when the parameter is added, I guess it will need adding to https://github.com/terraform-aws-modules/terraform-aws-rds-aurora too?

@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 8, 2021
@github-actions github-actions bot added this to the v3.63.0 milestone Oct 13, 2021
@github-actions
Copy link

This functionality has been released in v3.63.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@majidazimi
Copy link

This needs to be added to aurora provider as well. Specifying db_instance_parameter_group_name fails with An argument named "db_instance_parameter_group_name" is not expected here.

@azhurbilo
Copy link

@gdepuille thnx a lot for your TF example 👍
could you explain why both "aws_rds_cluster_parameter_group" and "aws_db_parameter_group" are used during major version upgrade?

In theory "aws_rds_cluster_parameter_group" is enough as these params applied to all cluster instances too, right?

Is "allow_major_version_upgrade = true" required for "aws_rds_cluster_parameter_group" or it's working only together with "aws_db_parameter_group"?

@github-actions
Copy link

github-actions bot commented Jun 2, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
6 participants