Skip to content

Commit

Permalink
Merge branch 'main' into mask_output_in_provider_framework
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jul 16, 2024
2 parents 091bf99 + 38e2ecf commit 026c1a7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The CDK team is committed to supporting our existing library of AWS L2 abstracti
Thank you to our community members that have contributed to the project. Below are some of the great contributions from the community! We'll continue to update this list as contributions come in, and please feel free to reach out on the cdk.dev slack workspace if you have any questions or feedback.

- 🚀 [EventBridge Pipes Alpha Construct](https://github.com/aws/aws-cdk/pull/28388) - [Raphael Manke](https://github.com/RaphaelManke)
- 🚀 [CodePipeline support for Git branch and file path based triggers](https://github.com/aws/aws-cdk/issues/29124) - [Kenta Goto](https://github.com/go-to-k)
- 🚀 [CodePipeline support for pipeline type V2 with pipeline-level variables and triggers](https://github.com/aws/aws-cdk/pull/28538) - [Kenta Goto](https://github.com/go-to-k)
- 🚀 [Cloudwatch Synthetics: Update to canary runtime support for NodeJS and Python](https://github.com/aws/aws-cdk/pull/29132) - [Henry Wilson](https://github.com/wilhen01)
- 🚀 [EFS File System Replication](https://github.com/aws/aws-cdk/pull/29347) - [
kazuho cryer-shinozuka](https://github.com/badmintoncryer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CrossRegionAwsSdkSingletonFunction } from '../../../custom-resource-han
*/
export interface CallAwsServiceCrossRegionProps extends sfn.TaskStateBaseProps {
/**
* The AWS service to call in AWS SDK for JavaScript v3 style.
* The AWS service to call in AWS SDK for JavaScript v3 format.
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/
* @example 's3'
Expand All @@ -26,9 +26,7 @@ export interface CallAwsServiceCrossRegionProps extends sfn.TaskStateBaseProps {
readonly action: string;

/**
* Parameters for the API action call.
*
* Use PascalCase for the parameter names.
* Parameters for the API action call in AWS SDK for JavaScript v3 format.
*
* @default - no parameters
*/
Expand Down Expand Up @@ -112,12 +110,6 @@ export class CallAwsServiceCrossRegion extends sfn.TaskStateBase {
if (!Token.isUnresolved(props.action) && !props.action.startsWith(props.action[0]?.toLowerCase())) {
throw new Error(`action must be camelCase, got: ${props.action}`);
}
if (props.parameters) {
const invalidKeys = Object.keys(props.parameters).filter((key) => !key.startsWith(key[0]?.toUpperCase()));
if (invalidKeys.length) {
throw new Error(`parameter names must be PascalCase, got: ${invalidKeys.join(', ')}`);
}
}

// props.service expects a service name in the AWS SDK for JavaScript v3 format.
// In some services, this format differs from the one used in IAM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,40 @@ test('with custom IAM action', () => {
});
});

test('parameters with camelCase', () => {
// WHEN
const task = new tasks.CallAwsServiceCrossRegion(stack, 'GetRestApi', {
service: 'api-gateway',
action: 'getRestApi',
parameters: {
restApiId: 'id',
},
region: 'us-east-1',
iamResources: ['*'],
retryOnServiceExceptions: false,
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::GetAtt': [
'CrossRegionAwsSdk8a0c93f3dbef4b71ac137aaf2048ce7eF7430F4F',
'Arn',
],
},
End: true,
Parameters: {
action: 'getRestApi',
region: 'us-east-1',
service: 'api-gateway',
parameters: {
restApiId: 'id',
},
},
});
});

test('throws with invalid integration pattern', () => {
expect(() => new tasks.CallAwsServiceCrossRegion(stack, 'GetObject', {
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
Expand Down Expand Up @@ -189,19 +223,6 @@ test('throws if action is not camelCase', () => {
})).toThrow(/action must be camelCase, got: GetObject/);
});

test('throws if parameters has keys as not PascalCase', () => {
expect(() => new tasks.CallAwsServiceCrossRegion(stack, 'GetObject', {
service: 's3',
action: 'getObject',
parameters: {
bucket: 'my-bucket',
key: sfn.JsonPath.stringAt('$.key'),
},
region: 'us-east-1',
iamResources: ['*'],
})).toThrow(/parameter names must be PascalCase, got: bucket, key/);
});

test('can pass additional IAM statements', () => {
// WHEN
const task = new tasks.CallAwsServiceCrossRegion(stack, 'DetectLabels', {
Expand Down

0 comments on commit 026c1a7

Please sign in to comment.