Skip to content

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Aug 28, 2025

WIP

Issue # (if applicable)

Closes #31566.

Reason for this change

The Secret.grantRead() method was missing the secretsmanager:BatchGetSecretValue permission, preventing developers from using the AWS SDK's BatchGetSecretValueCommand without manually configuring additional IAM permissions. This created an inconsistent developer experience where batch operations required extra IAM setup beyond the standard CDK grant methods.

Description of changes

Enhanced the Secret.grantRead() method to include secretsmanager:BatchGetSecretValue permission alongside the existing GetSecretValue and DescribeSecret permissions. This change:

  • Adds 'secretsmanager:BatchGetSecretValue' to the actions array in the grantRead() method
  • Updates all related unit tests to expect the new permission in generated IAM policies
  • Maintains full backward compatibility - existing code continues to work unchanged
  • Follows the established pattern used by other AWS services (like DynamoDB) that include batch operations by default
  • Preserves all existing functionality including version stage constraints, KMS integration, and cross-account validation

Describe any new or updated permissions being added

IAM permissions: Added secretsmanager:BatchGetSecretValue permission to IAM policies generated by Secret.grantRead() method.

Resource access: The new permission uses the same resource scoping as existing permissions (secret ARN with proper wildcards for version stages). No additional resource access patterns are introduced.

Description of how you validated changes

  • Unit tests: Updated existing grantRead test cases to verify secretsmanager:BatchGetSecretValue is included in generated IAM policies. All tests pass with the enhanced permission set.
  • Integration tests: Existing integration tests continue to pass, confirming CloudFormation deployment succeeds with the enhanced IAM policies and all functionality remains intact.

Checklist


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

@github-actions github-actions bot added bug This issue is a bug. p2 labels Aug 28, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team August 28, 2025 21:20
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 28, 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.

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Secrets Manager: Not authorized to perform BatchGetSecretValue
2 participants