Skip to content

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Aug 4, 2025

Add bedrockagent: 'bedrock' mapping to iamServiceMap in CallAwsService to ensure correct IAM permissions are generated. Without this mapping, Step Functions tasks using service='bedrockagent' would generate incorrect 'bedrockagent:action' IAM permissions instead of the correct 'bedrock:action' format required by AWS IAM.

Fixes issue where Bedrock Agent actions like startIngestionJob and getIngestionJob would fail with access denied errors due to incorrect IAM policy generation.

Issue # (if applicable)

Closes #35146

Reason for this change

The CDK's Step Functions SDK integration (CallAwsService) generates incorrect IAM permissions for Amazon Bedrock Agent actions. When using service="bedrockagent" with actions like startIngestionJob and getIngestionJob, the auto-generated IAM policy incorrectly uses the bedrockagent: service prefix instead of the correct bedrock: prefix.

This causes Step Functions executions to fail with access denied errors because AWS IAM uses bedrock: as the service prefix for all Bedrock-related actions, including Bedrock Agent operations.

Description of changes

Core Change:

  • Added bedrockagent: 'bedrock' mapping to the existing iamServiceMap object in CallAwsService class
  • This follows the established pattern used by 6 other service mappings (e.g., mwaa: 'airflow', sfn: 'states')

Test Coverage:

  • Added comprehensive test case 'IAM policy for bedrockagent' following existing test patterns
  • Verifies that service: 'bedrockagent' generates correct bedrock:startIngestionJob IAM action
  • Ensures no regressions in existing service mappings

Files Modified:

  • packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/aws-sdk/call-aws-service.ts - Added mapping
  • packages/aws-cdk-lib/aws-stepfunctions-tasks/test/aws-sdk/call-aws-service.test.ts - Added test

Design Decision:
This approach was chosen because it follows the existing architecture pattern and requires minimal code changes while maintaining backward compatibility. Alternative approaches like modifying the IAM action generation logic would be more invasive and risky.

Describe any new or updated permissions being added

No new permissions are being added. This change corrects the IAM service prefix from bedrockagent: to bedrock: for existing Bedrock Agent actions. The actions themselves (startIngestionJob, getIngestionJob, etc.) remain the same.

Description of how you validated changes

Unit Tests:

  • Added new test case 'IAM policy for bedrockagent' that verifies correct IAM policy generation
  • All existing tests pass, confirming no regressions
  • Test follows established pattern used by other service mapping tests

Manual Testing:

  • Verified that CallAwsService with service: 'bedrockagent' now generates bedrock:startIngestionJob instead of bedrockagent:startIngestionJob
  • Confirmed IAM policy structure matches expected format

Test Results:

  • New test: IAM policy for bedrockagent - PASSED
  • All 15 existing tests - PASSED
  • No regressions detected

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add bedrockagent: 'bedrock' mapping to iamServiceMap in CallAwsService to ensure
correct IAM permissions are generated. Without this mapping, Step Functions tasks
using service='bedrockagent' would generate incorrect 'bedrockagent:action' IAM
permissions instead of the correct 'bedrock:action' format required by AWS IAM.

Fixes issue where Bedrock Agent actions like startIngestionJob and getIngestionJob
would fail with access denied errors due to incorrect IAM policy generation.
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Aug 4, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 4, 2025 21:13
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 4, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

(This review is outdated)

@pahud
Copy link
Contributor Author

pahud commented Aug 4, 2025

Exemption Request

Unit tests are sufficient - They verify the IAM policy generation works correctly
Time/Resource efficiency - Integration tests are expensive and this is a low-risk change
AWS CDK practices - Similar service mapping PRs typically don't require integration test runs

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Aug 4, 2025
@pahud pahud marked this pull request as ready for review August 4, 2025 21:20
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 99dfd0c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 4, 2025
@Abogical Abogical self-assigned this Aug 7, 2025
Copy link
Member

@Abogical Abogical left a comment

Choose a reason for hiding this comment

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

Hi @pahud! I will request a security review for this, I'll come back to this when I have an update.

Copy link
Member

@Abogical Abogical left a comment

Choose a reason for hiding this comment

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

Thank you!

@Abogical Abogical added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Aug 22, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 22, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 22, 2025 09:31

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

mergify bot commented Aug 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Aug 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 86638f6 into aws:main Aug 22, 2025
18 checks passed
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stepfunctions-tasks: Step Functions SDK Integration generates incorrect IAM permissions for Bedrock Agent actions
3 participants