Skip to content

Conversation

@jdebuseamazon
Copy link
Contributor

Issue # (if applicable)

Closes #34397

Reason for this change

Dynamic references allow an AWS Secrets Manager Secret to be retrieved for use in another AWS CloudFormation resource. Currently the key strings for dynamic references must be created using string manipulation, eg

const passwordKey = `${mySecret.secretArn}:SecretString:password`;

Description of changes

The existing static secretsManager function in aws-cdk-lib/core includes code to generate a dynamic reference key string. This code was therefore extracted into a new static cfnDynamicReferenceKey function to make it available outside the secretsManager function. Using this new static function the above code example becomes

const passwordKey = SecretValue.cfnDynamicReferenceKey(mySecret.secretArn, { jsonField: 'password' });

A new instance method cfnDynamicReferenceKey was also created in the Secret class in aws-cdk-lib/aws-secretsmanager, which calls the new static cfnDynamicReferenceKey function for the secret that it represents. Using this new instance method the above example becomes

const passwordKey = mySecret.cfnDynamicReferenceKey({ jsonField: 'password' });

Description of how you validated changes

Unit tests and an integration test.

Checklist


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

@jdebuseamazon jdebuseamazon requested a review from a team as a code owner July 29, 2025 15:31
@aws-cdk-automation aws-cdk-automation requested a review from a team July 29, 2025 15:31
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jul 29, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 29, 2025
@jdebuseamazon jdebuseamazon force-pushed the jdebuseamazon/secret-dynamic-reference-key branch from 83c4775 to fb7abb6 Compare July 30, 2025 15:31
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

…to obtain a literal (unresolved by CloudFormation) dynamic reference key
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)

@jdebuseamazon jdebuseamazon force-pushed the jdebuseamazon/secret-dynamic-reference-key branch from 8a2b1a7 to c76a380 Compare August 18, 2025 14:04
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 18, 2025 14:06

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

@Abogical Abogical self-assigned this Nov 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.

Thanks!

@mergify
Copy link
Contributor

mergify bot commented Nov 10, 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
Copy link
Contributor

mergify bot commented Nov 10, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/analytics-metadata-updater.yml without workflows permission.

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 10, 2025
@mergify
Copy link
Contributor

mergify bot commented Nov 10, 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
Copy link
Contributor

mergify bot commented Nov 10, 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
Copy link
Contributor

mergify bot commented Nov 10, 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 457aa99 into aws:main Nov 10, 2025
19 of 20 checks passed
@github-actions
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 Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-secretsmanager): Provide method to obtain a literal (unresolved by CloudFormation) dynamic reference string for a secret's JSON key

3 participants