chore(stepfunctions-tasks): make iamResources optional in CallAwsService #35239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #35236.
Reason for this change
The current
CallAwsServiceconstruct requires theiamResourcesparameter, forcing users to provide dummy or placeholder ARN values in scenarios where automatic IAM policy generation is not appropriate or possible. This creates several pain points:iamResources['*']or dummy ARNs, making code less maintainable and confusingThis change enables proper manual IAM management for complex scenarios while maintaining full backward compatibility with existing code.
Description of changes
iamResourcesparameter optional inCallAwsServiceOptionsinterface (iamResources: string[]→iamResources?: string[])iamResourcesis undefinedadditionalIamStatementsare provided withoutiamResourcesThe implementation follows existing CDK patterns found in other constructs like
InvokeActivity, wheretaskPoliciescan be conditionally assigned. The framework'sTaskStateBasealready safely handlesundefinedtaskPolicies by defaulting to an empty array.Key implementation pattern:
This change enables use cases like:
Describe any new or updated permissions being added
N/A - This change does not add new permissions. Instead, it provides an option to skip automatic IAM policy generation, requiring users to manually manage permissions when
iamResourcesis omitted.Description of how you validated changes
Unit tests: Added 3 comprehensive test cases to
call-aws-service.test.ts:CallAwsService without iamResources - no IAM policy generated: Verifies no IAM policies are created wheniamResourcesis omittedCallAwsService with only additionalIamStatements - only additional statements included: Tests edge case where only additional statements are providedCallAwsService without iamResources and without additionalIamStatements - no IAM policy generated: Confirms complete manual IAM management scenarioAll existing 14 unit tests continue to pass unchanged, ensuring full backward compatibility.
Integration tests: Created new integration test
integ.call-aws-service-optional-iam.tsdemonstrating:CallAwsServicecalling itselfadditionalIamStatementsChecklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license