Skip to content

Commit 5bfff38

Browse files
dontirunmadeline-k
authored andcommitted
fix(integ-tests): AwsApiCall Custom Resource length could be greater than 60 characters (aws#22119)
Limits the resource type name to 60 characters to account for CloudFormation limitations with Custom Resource Resource Types Closes aws#22055 ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0aedf44 commit 5bfff38

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Diff for: packages/@aws-cdk/integ-tests/lib/assertions/sdk.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { CustomResource, Reference, Lazy, CfnResource, Stack, ArnFormat } from '@aws-cdk/core';
1+
import { ArnFormat, CfnResource, CustomResource, Lazy, Reference, Stack } from '@aws-cdk/core';
22
import { Construct, IConstruct } from 'constructs';
33
import { EqualsAssertion } from './assertions';
4-
import { ExpectedResult, ActualResult } from './common';
4+
import { ActualResult, ExpectedResult } from './common';
55
import { AssertionsProvider, SDK_RESOURCE_TYPE_PREFIX } from './providers';
66

77
/**
@@ -113,7 +113,7 @@ export interface AwsApiCallOptions {
113113
/**
114114
* Options for creating an SDKQuery provider
115115
*/
116-
export interface AwsApiCallProps extends AwsApiCallOptions {}
116+
export interface AwsApiCallProps extends AwsApiCallOptions { }
117117

118118
/**
119119
* Construct that creates a custom resource that will perform
@@ -142,7 +142,7 @@ export class AwsApiCall extends Construct implements IAwsApiCall {
142142
flattenResponse: Lazy.string({ produce: () => this.flattenResponse }),
143143
salt: Date.now().toString(),
144144
},
145-
resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`,
145+
resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`.substring(0, 60),
146146
});
147147

148148
// Needed so that all the policies set up by the provider should be available before the custom resource is provisioned.

Diff for: packages/@aws-cdk/integ-tests/test/assertions/deploy-assert.test.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Template } from '@aws-cdk/assertions';
22
import { App, Stack } from '@aws-cdk/core';
3-
import { LogType, InvocationType, ExpectedResult, ActualResult } from '../../lib/assertions';
3+
import { ActualResult, ExpectedResult, InvocationType, LogType } from '../../lib/assertions';
44
import { DeployAssert } from '../../lib/assertions/private/deploy-assert';
55

66
describe('DeployAssert', () => {
@@ -145,5 +145,22 @@ describe('DeployAssert', () => {
145145
template.resourceCountIs('Custom::DeployAssert@SdkCallMyServiceMyApi1', 1);
146146
template.resourceCountIs('Custom::DeployAssert@SdkCallMyServiceMyApi2', 1);
147147
});
148+
149+
test('custom resource type length is truncated when greater than 60 characters', () => {
150+
// GIVEN
151+
const app = new App();
152+
153+
// WHEN
154+
const deplossert = new DeployAssert(app);
155+
deplossert.awsApiCall('Pangram', 'TheQuickBrownFoxJumpsOverTheLazyDog');
156+
157+
// THEN
158+
const truncatedType = 'Custom::DeployAssert@SdkCallPangramTheQuickBrownFoxJumpsOver';
159+
expect(truncatedType.length).toEqual(60);
160+
161+
const template = Template.fromStack(deplossert.scope);
162+
template.resourceCountIs('AWS::Lambda::Function', 1);
163+
template.resourceCountIs(truncatedType, 1);
164+
});
148165
});
149166
});

0 commit comments

Comments
 (0)