Skip to content

(integ-tests): sdk and assertions can generate custom resource types with more than 60 characters causing validation errors #22055

@dontirun

Description

@dontirun

Describe the bug

I can't use awsApiCall('Redshift', 'describeClusters', {...}) due to validation errors in CloudFormation.

Expected Behavior

Using assertions.awsApiCall generates a valid Resource Type that doesn't throw errors

Current Behavior

I received the following error when attempting to write integ tests using assertions.awsApiCall

Deployment failed: Error: Stack Deployments Failed: ValidationError: 1 validation error detected: Value '[AWS::IAM::Role, AWS::Lambda::Function, Custom::DeployAssert@SdkCallRedshiftdescribeClusterParameters]' at 'typeNameList' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 204, Member must have length greater than or equal to 10, Member must satisfy regular expression pattern: [A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}(::MODULE){0,1}]

Custom::DeployAssert@SdkCallRedshiftdescribeClusterParameters did not match the expected regex pattern.

Edit:

Well it looks like this is the actual problem

from the docs

You can specify a custom resource type name up to a maximum length of 60 characters.

Custom::DeployAssert@SdkCallRedshiftdescribeClusterParameters. Just so happens to be 61 characters long ...

Reproduction Steps

Cut down integration test file

import * as ec2 from '@aws-cdk/aws-ec2';
import * as redshift from '@aws-cdk/aws-redshift';
import * as cdk from '@aws-cdk/core';
import * as integ from '@aws-cdk/integ-tests';

const app = new cdk.App();

const stack = new cdk.Stack(app, 'foo')
const vpc = new ec2.Vpc(stack, 'Vpc');
const cluster = new redshift.Cluster(stack, 'Cluster', {
  vpc: vpc,
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
  masterUser: {
    masterUsername: 'admin',
  },
});

const test = new integ.IntegTest(app, 'aws-cdk-redshift-reboot-test', {
  testCases: [stack],
  stackUpdateWorkflow: true,
  diffAssets: true,
});

test.assertions.awsApiCall('Redshift', 'describeClusters', {
  ClusterIdentifier: cluster.clusterName,
});

app.synth();

Possible Solution

Remove/replace the @ symbol or provide documentation on how to opt-in to allow that symbol

Additional Information/Context

I removed the @ symbol from the types defined here and rebuilt the integ-tests module.

When I did this, the problem went away

CDK CLI Version

2.41.0

Framework Version

No response

Node.js Version

v16.16.0

OS

OsX

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/assertionsRelated to the @aws-cdk/assertv2 packagebugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions