diff --git a/packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts b/packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts index 97972e4c568ba..b79ecc4bce356 100644 --- a/packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts +++ b/packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts @@ -1,7 +1,7 @@ -import { CustomResource, Reference, Lazy, CfnResource, Stack, ArnFormat } from '@aws-cdk/core'; +import { ArnFormat, CfnResource, CustomResource, Lazy, Reference, Stack } from '@aws-cdk/core'; import { Construct, IConstruct } from 'constructs'; import { EqualsAssertion } from './assertions'; -import { ExpectedResult, ActualResult } from './common'; +import { ActualResult, ExpectedResult } from './common'; import { AssertionsProvider, SDK_RESOURCE_TYPE_PREFIX } from './providers'; /** @@ -113,7 +113,7 @@ export interface AwsApiCallOptions { /** * Options for creating an SDKQuery provider */ -export interface AwsApiCallProps extends AwsApiCallOptions {} +export interface AwsApiCallProps extends AwsApiCallOptions { } /** * Construct that creates a custom resource that will perform @@ -142,7 +142,7 @@ export class AwsApiCall extends Construct implements IAwsApiCall { flattenResponse: Lazy.string({ produce: () => this.flattenResponse }), salt: Date.now().toString(), }, - resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`, + resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`.substring(0, 60), }); // Needed so that all the policies set up by the provider should be available before the custom resource is provisioned. diff --git a/packages/@aws-cdk/integ-tests/test/assertions/deploy-assert.test.ts b/packages/@aws-cdk/integ-tests/test/assertions/deploy-assert.test.ts index 5a287200e9fca..bbc2609822356 100644 --- a/packages/@aws-cdk/integ-tests/test/assertions/deploy-assert.test.ts +++ b/packages/@aws-cdk/integ-tests/test/assertions/deploy-assert.test.ts @@ -1,6 +1,6 @@ import { Template } from '@aws-cdk/assertions'; import { App, Stack } from '@aws-cdk/core'; -import { LogType, InvocationType, ExpectedResult, ActualResult } from '../../lib/assertions'; +import { ActualResult, ExpectedResult, InvocationType, LogType } from '../../lib/assertions'; import { DeployAssert } from '../../lib/assertions/private/deploy-assert'; describe('DeployAssert', () => { @@ -145,5 +145,22 @@ describe('DeployAssert', () => { template.resourceCountIs('Custom::DeployAssert@SdkCallMyServiceMyApi1', 1); template.resourceCountIs('Custom::DeployAssert@SdkCallMyServiceMyApi2', 1); }); + + test('custom resource type length is truncated when greater than 60 characters', () => { + // GIVEN + const app = new App(); + + // WHEN + const deplossert = new DeployAssert(app); + deplossert.awsApiCall('Pangram', 'TheQuickBrownFoxJumpsOverTheLazyDog'); + + // THEN + const truncatedType = 'Custom::DeployAssert@SdkCallPangramTheQuickBrownFoxJumpsOver'; + expect(truncatedType.length).toEqual(60); + + const template = Template.fromStack(deplossert.scope); + template.resourceCountIs('AWS::Lambda::Function', 1); + template.resourceCountIs(truncatedType, 1); + }); }); });