Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(integ-tests): apply correct IAM policy to waiterProvider #28424

Merged
merged 8 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export interface LambdaInvokeFunctionProps {

/**
* An AWS Lambda Invoke function API call.
* Use this istead of the generic AwsApiCall in order to
* Use this instead of the generic AwsApiCall in order to
* invoke a lambda function. This will automatically create
* the correct permissions to invoke the function
*/
Expand Down Expand Up @@ -250,6 +250,19 @@ export class LambdaInvokeFunction extends AwsApiCall {
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
resourceName: props.functionName,
})]);

// If using `waitForAssertions`, do the same for `waiterProvider` as above.
Aspects.of(this).add({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Resource-based policy for Lambda is created in the part shown in the link, but it is not created here because invoking Lambda from Lambda is possible if the appropriate Policy is granted to the execution role of the invoking Lambda.

new CfnResource(this, 'Invoke', {

If you have any concerns, I would really appreciate it if you could let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this but -- can you document why you've used an Aspect so that others who stumble on your code will understand the decision please

visit(node: IConstruct) {
if (node instanceof AwsApiCall && node.waiterProvider) {
node.waiterProvider.addPolicyStatementFromSdkCall('Lambda', 'invokeFunction', [stack.formatArn({
service: 'lambda',
resource: 'function',
arnFormat: ArnFormat.COLON_RESOURCE_NAME,
resourceName: props.functionName,
})]);
}
},
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.