Skip to content

Commit

Permalink
fix(custom-resources): Role Session Name can exceed maximum size
Browse files Browse the repository at this point in the history
The provider used the physical resource id and the epoch time as
the name of the assumed role session. Unfortunately, the maximum
length of these two fields combined can exceed the 64 character
limit on a role session name.

The role session name is not extremely important, it's purely
for human consumption. Nothing ensures that every assumed role
session has a unique role session name. For a unique identifier,
the session's access key identifier should be used instead.

This change caps the generate role session name at 64 characters
and moves the timestamp to the front, so that it is not the
portion of the name that is truncated.
  • Loading branch information
Matt Berry committed Sep 28, 2021
1 parent d21561a commit bbc5620
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export async function handler(event: AWSLambda.CloudFormationCustomResourceEvent

const params = {
RoleArn: call.assumedRoleArn,
RoleSessionName: `${physicalResourceId}-${timestamp}`,
RoleSessionName: `${timestamp}-${physicalResourceId}`.substring(0, 64),
};

AWS.config.credentials = new AWS.ChainableTemporaryCredentials({
Expand Down

0 comments on commit bbc5620

Please sign in to comment.