Skip to content

Commit d63c2a0

Browse files
authored
Merge branch 'main' into road-map-contribution
2 parents d5e370f + 5d6ace8 commit d63c2a0

2 files changed

Lines changed: 36 additions & 23 deletions

File tree

packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/lambda/call-aws-service-cross-region.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CrossRegionAwsSdkSingletonFunction } from '../../../custom-resource-han
1111
*/
1212
export interface CallAwsServiceCrossRegionProps extends sfn.TaskStateBaseProps {
1313
/**
14-
* The AWS service to call in AWS SDK for JavaScript v3 style.
14+
* The AWS service to call in AWS SDK for JavaScript v3 format.
1515
*
1616
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/
1717
* @example 's3'
@@ -26,9 +26,7 @@ export interface CallAwsServiceCrossRegionProps extends sfn.TaskStateBaseProps {
2626
readonly action: string;
2727

2828
/**
29-
* Parameters for the API action call.
30-
*
31-
* Use PascalCase for the parameter names.
29+
* Parameters for the API action call in AWS SDK for JavaScript v3 format.
3230
*
3331
* @default - no parameters
3432
*/
@@ -112,12 +110,6 @@ export class CallAwsServiceCrossRegion extends sfn.TaskStateBase {
112110
if (!Token.isUnresolved(props.action) && !props.action.startsWith(props.action[0]?.toLowerCase())) {
113111
throw new Error(`action must be camelCase, got: ${props.action}`);
114112
}
115-
if (props.parameters) {
116-
const invalidKeys = Object.keys(props.parameters).filter((key) => !key.startsWith(key[0]?.toUpperCase()));
117-
if (invalidKeys.length) {
118-
throw new Error(`parameter names must be PascalCase, got: ${invalidKeys.join(', ')}`);
119-
}
120-
}
121113

122114
// props.service expects a service name in the AWS SDK for JavaScript v3 format.
123115
// In some services, this format differs from the one used in IAM.

packages/aws-cdk-lib/aws-stepfunctions-tasks/test/lambda/call-aws-service-cross-region.test.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,40 @@ test('with custom IAM action', () => {
162162
});
163163
});
164164

165+
test('parameters with camelCase', () => {
166+
// WHEN
167+
const task = new tasks.CallAwsServiceCrossRegion(stack, 'GetRestApi', {
168+
service: 'api-gateway',
169+
action: 'getRestApi',
170+
parameters: {
171+
restApiId: 'id',
172+
},
173+
region: 'us-east-1',
174+
iamResources: ['*'],
175+
retryOnServiceExceptions: false,
176+
});
177+
178+
// THEN
179+
expect(stack.resolve(task.toStateJson())).toEqual({
180+
Type: 'Task',
181+
Resource: {
182+
'Fn::GetAtt': [
183+
'CrossRegionAwsSdk8a0c93f3dbef4b71ac137aaf2048ce7eF7430F4F',
184+
'Arn',
185+
],
186+
},
187+
End: true,
188+
Parameters: {
189+
action: 'getRestApi',
190+
region: 'us-east-1',
191+
service: 'api-gateway',
192+
parameters: {
193+
restApiId: 'id',
194+
},
195+
},
196+
});
197+
});
198+
165199
test('throws with invalid integration pattern', () => {
166200
expect(() => new tasks.CallAwsServiceCrossRegion(stack, 'GetObject', {
167201
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
@@ -189,19 +223,6 @@ test('throws if action is not camelCase', () => {
189223
})).toThrow(/action must be camelCase, got: GetObject/);
190224
});
191225

192-
test('throws if parameters has keys as not PascalCase', () => {
193-
expect(() => new tasks.CallAwsServiceCrossRegion(stack, 'GetObject', {
194-
service: 's3',
195-
action: 'getObject',
196-
parameters: {
197-
bucket: 'my-bucket',
198-
key: sfn.JsonPath.stringAt('$.key'),
199-
},
200-
region: 'us-east-1',
201-
iamResources: ['*'],
202-
})).toThrow(/parameter names must be PascalCase, got: bucket, key/);
203-
});
204-
205226
test('can pass additional IAM statements', () => {
206227
// WHEN
207228
const task = new tasks.CallAwsServiceCrossRegion(stack, 'DetectLabels', {

0 commit comments

Comments
 (0)