aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

(cdk-lib/rds): No longer able to create output for DB Parameter Group Name

Open mikemill opened this issue 4 years ago • 3 comments

Describe the bug

I'm trying to create a stack output with the DbParaemterGroupName for use in a different stack. I was previously able to do this as of Oct 24. Now, when I deploy I get an error message.

Expected Behavior

Creation of a stack output with the resolved parameter group name.

Current Behavior

When deploying the stack I receive the following error message: Requested attribute DBParameterGroupName must be a readonly property in schema for AWS::RDS::DBParameterGroup

The stack then rolls back

Reproduction Steps

This is an example stack that produces the issue.

import * as cdk from "aws-cdk-lib";
import * as rds from "aws-cdk-lib/aws-rds";

import { Construct } from "constructs";

export class ExampleStack extends cdk.Stack {
  constructor(scope: Construct, name: string, props?: cdk.StackProps) {
    super(scope, name, props)

    const pg = new rds.ParameterGroup(this, "parameterGroup", {
      engine: rds.DatabaseInstanceEngine.mysql({
        version: rds.MysqlEngineVersion.VER_8_0,
      }),
      parameters: {
        time_zone: "US/Pacific",
      },
    });

    pg.bindToInstance({});

    new cdk.CfnOutput(this, 'parameterGroupOutput', {
      value: (pg.node.defaultChild as rds.CfnDBParameterGroup).attrDbParameterGroupName,
    });
  }
}

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.50.0 (build 4c11af6)

Framework Version

No response

Node.js Version

v16.14.2

OS

Mac OS

Language

Typescript

Language Version

Typescript 4.7.4

Other information

No response

mikemill avatar Nov 04 '22 14:11 mikemill

Thanks for reporting this issue @mikemill,

It looks like this attribute has been removed and you cannot use it in CloudFormation anymore. It was removed in the most recent CloudFormation resource spec, and also doesn't appear on CloudFormation documentation as a return value.

Instead, you can use .ref which returns the name as well. It's possible the property you were using has been removed due to redundancy with ref.

peterwoodworth avatar Nov 05 '22 00:11 peterwoodworth

@peterwoodworth Thank you very much for the information. I have confirmed that changing attrDbParameterGroupName to ref works to export the parameter group name.

mikemill avatar Nov 05 '22 13:11 mikemill

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Mar 15 '23 22:03 github-actions[bot]