Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(custom-resources): Role Session Name can exceed maximum size #16680

Merged
merged 2 commits into from
Oct 21, 2021

Conversation

AWS-MattB
Copy link
Contributor

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.

https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html

2021-09-28T01:36:45.780Z	fc8f6e02-d746-441b-b07c-5e2b836087a0	INFO	Error [CredentialsError]: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'CredentialsError',
  time: 2021-09-28T01:36:45.659Z,
  requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
  statusCode: 400,
  retryable: false,
  retryDelay: 38.712174099272744,
  originalError: {
    message: 'Could not load credentials from ChainableTemporaryCredentials',
    code: 'CredentialsError',
    time: 2021-09-28T01:36:45.659Z,
    requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
    statusCode: 400,
    retryable: false,
    retryDelay: 38.712174099272744,
    originalError: {
      message: "1 validation error detected: Value 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-1632793004697' at 'roleSessionName' failed to satisfy constraint: Member must have length less than or equal to 64",
      code: 'ValidationError',
      time: 2021-09-28T01:36:45.657Z,
      requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
      statusCode: 400,
      retryable: false,
      retryDelay: 38.712174099272744
    }
  }
}

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

@gitpod-io
Copy link

gitpod-io bot commented Sep 28, 2021

@AWS-MattB AWS-MattB force-pushed the role-session-name branch 2 times, most recently from bbc5620 to 8ddcb40 Compare September 28, 2021 17:25
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.
@peterwoodworth peterwoodworth added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes labels Oct 21, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 21, 2021

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: aa5de03
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 3617b70 into aws:master Oct 21, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 21, 2021

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

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…#16680)

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.

https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html


```
2021-09-28T01:36:45.780Z	fc8f6e02-d746-441b-b07c-5e2b836087a0	INFO	Error [CredentialsError]: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)
    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)
    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'CredentialsError',
  time: 2021-09-28T01:36:45.659Z,
  requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
  statusCode: 400,
  retryable: false,
  retryDelay: 38.712174099272744,
  originalError: {
    message: 'Could not load credentials from ChainableTemporaryCredentials',
    code: 'CredentialsError',
    time: 2021-09-28T01:36:45.659Z,
    requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
    statusCode: 400,
    retryable: false,
    retryDelay: 38.712174099272744,
    originalError: {
      message: "1 validation error detected: Value 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-1632793004697' at 'roleSessionName' failed to satisfy constraint: Member must have length less than or equal to 64",
      code: 'ValidationError',
      time: 2021-09-28T01:36:45.657Z,
      requestId: '8aedc751-a552-449c-af2b-4566e3160d98',
      statusCode: 400,
      retryable: false,
      retryDelay: 38.712174099272744
    }
  }
}
```

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants