aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.55k stars 3.87k forks source link

redshift: CfnCluster CreateCluster : Debug message #30619

Open wtromano-aws opened 3 months ago

wtromano-aws commented 3 months ago

Describe the bug

Redshift cluster would not deploy, and the error message was "Error Message: Not Found Resource of type '%s' with identifier '%s' was not found". This led to a trial-and-error debug session that took some time. This issue asks to update this error messaging.

Expected Behavior

The condition should give a more descriptive error, such as:

ManageMasterPassword is false/not set and MasterUserPassword is not provided.

Current Behavior

HelloCdkStack | 0/3 | 12:50:14 PM | UPDATE_FAILED | AWS::Redshift::Cluster | DemoCfnCluster Resource handler returned message: "Cluster democlusterid5 Not Found Resource of type '%s' with identifier '%s' was not found." (RequestToken: ec18d1c3-6003-09e1-f260-5f747d4619c1, HandlerErrorCode: NotFound)

Reproduction Steps

CreateCluster

Possible Solution

The condition should give a more descriptive error, such as:

ManageMasterPassword is false/not set and MasterUserPassword is not provided.

Additional Information/Context

N.A.

CDK CLI Version

2.142.1

Framework Version

2.142.1

Node.js Version

10.9.2

OS

MacOS

Language

TypeScript

Language Version

5.3.3

Other information

HelloCdkStack | 0/3 | 12:50:14 PM | UPDATE_FAILED | AWS::Redshift::Cluster | DemoCfnCluster Resource handler returned message: "Cluster democlusterid5 Not Found Resource of type '%s' with identifier '%s' was not found." (RequestToken: ec18d1c3-6003-09e1-f260-5f747d4619c1, HandlerErrorCode: NotFound)

"devDependencies": { "@types/jest": "^29.5.12", "@types/node": "20.12.7", "jest": "^29.7.0", "ts-jest": "^29.1.2", "aws-cdk": "2.141.0", "ts-node": "^10.9.2", "typescript": "~5.4.5" }, "dependencies": { "aws-cdk-lib": "2.141.0", "constructs": "^10.0.0", "source-map-support": "^0.5.21" }

amcginn commented 3 months ago

Here's a minimal Stack that produces this error. Uncommenting the manageMasterPassword prop successfully deploys the stack. Note, the VPC ID was removed here but should refer to an existing VPC.

import * as cdk from 'aws-cdk-lib';
import * as redshift from 'aws-cdk-lib/aws-redshift'
import { Construct } from 'constructs';
import * as ec2 from "aws-cdk-lib/aws-ec2";

export class HelloCdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const vpc = ec2.Vpc.fromLookup(this, `demo-vpc-lookup`, {
      vpcId: 'vpc-xxxx' // look up existing account VPC
    })

    const privateSubnetIds = vpc.privateSubnets.map((subnet) => subnet.subnetId)

    const subnetGroup = new redshift.CfnClusterSubnetGroup(this, `demosubnetgroup`, {
      description: 'Private subnets for the current environment\'s VPC',
      subnetIds: privateSubnetIds
    })

    new redshift.CfnCluster(this, 'DemoCfnCluster', {
      clusterType: 'single-node',
      dbName: 'demodbname',
      masterUsername: 'master-demo-username',
      nodeType: 'dc2.large',

      // the properties below are optional
      clusterSubnetGroupName: subnetGroup.attrClusterSubnetGroupName, // required to create cluster in VPC
      // manageMasterPassword: true, // must be set, since MasterUserPassword is not set
    });
  }
}
pahud commented 3 months ago

redshift.CfnCluster is L1 construct which essentially synthesize AWS::Redshift::Cluster. The error message is from cloudformation, not CDK. I am afraid this is not something CDK can do.

Please help report this issue to https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues to help the cloudformation team prioritize. Thank you.

pahud commented 3 months ago

internal tracking V1426176880

amcginn commented 3 months ago

If it's applicable, the L2 aws-redshift-alpha workflow produces the same error. It could be evaluated for defaulting the manageMasterPassword to true when the password itself isn't given.