Error when deploying AWS CDK nested stack: ValidationError for stackName

813 Views Asked by At

I'm encountering an error when trying to deploy a nested AWS CDK stack as part of my main stack, and I'm having trouble understanding and resolving it.

The error message I'm receiving is as follows:

Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]|arn:[-a-zA-Z0-9:/._+]; Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1

Error occurred while monitoring stack: Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*; Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1
        at Request.extractError (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:46430)
        at Request.callListeners (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:90083)
        at Request.emit (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:89531)
        at Request.emit (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:196289)
        at Request.transition (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:189841)
        at AcceptorStateMachine.runTo (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:154713)
        at /home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:155043
        at Request.<anonymous> (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:190133)
        at Request.<anonymous> (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:196364)
        at Request.callListeners (/home/pankaj/work/optimizory/rmsis-cdk-prod/node_modules/aws-cdk/lib/index.js:362:90251) {
      code: 'ValidationError',
      time: 2023-10-11T07:11:47.628Z,
      requestId: '624d1704-0a35-4d37-8cfc-3a21d1ead226',
      statusCode: 400,
      retryable: false,
      retryDelay: 288.2824464668148
    }

I'm using nested stacks in AWS CDK, and it appears that this error is related to the stackName of one of the nested stacks. I've checked my code, and it appears to follow the naming constraints for AWS CloudFormation stack names.

Here's a simplified version of my CDK code, with a focus on the nested stack:

const stack = new ClientStack(this, "cli-"+clients[i].tenantId , stackprops);

I'm using AWS CDK version 2.84.0

1

There are 1 best solutions below

0
dinesh mane On

It's a known issue on the previous aws-cdk version. I upgraded the aws-cdk globally and it resolved the issue. Documentation. GitHub issue

npm install -g aws-cdk