View a markdown version of this page

Retrieving secrets across accounts with role chaining in AWS Systems Manager Cloud Extensions - AWS Systems Manager

Retrieving secrets across accounts with role chaining in AWS Systems Manager Cloud Extensions

To retrieve a secret as another IAM role, add roleArn to a query or path request. The runtime assumes the role from the principal of the extension, and the extension keeps a separate cache for each role. The following requirements apply:

  • The principal of the extension must have sts:AssumeRole permission on the target role.

  • The target role must have secretsmanager:GetSecretValue and secretsmanager:DescribeSecret permissions for the secrets.

  • The trust policy of the target role must allow the principal of the extension to assume the role.

To get a secret in another account with curl, run the following command:

curl -v \ --aws-sigv4 "aws:amz:us-west-2:secretsmanager" \ --user "ACCESS_KEY_ID:SECRET_KEY" \ -H "X-Aws-Parameters-Secrets-Token: YOUR_SSRF_TOKEN" \ 'http://localhost:5333/secretsmanager/get?secretId=YOUR_SECRET_ID&roleArn=arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME'

There's no limit on the number of roles. The runtime keeps the credentials of an assumed role. A session lasts one hour, and the runtime refreshes it one minute before it expires, for as long as the runtime runs. The extension caches the secret values for each role until its settings change.

The extension returns the following errors for role chaining:

  • 400 BadRequestException – The roleArn doesn't match arn:partition:iam::account:role/name.

  • 400 AccessDeniedException – The extension couldn't assume the role. Verify that the trust policy of the target role allows the principal of the extension to assume the role.