aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

fix(cli): failure to get credentials when session token is not set #32134

Closed otaviomacedo closed 1 day ago

otaviomacedo commented 1 day ago

In Node.js, if you assign undefined to an environment variable, that variable ends up having the string "undefined".

If we are using IAM user credentials, AWS_SESSION_TOKEN should not be set, but because we were not handling this edge case, it was getting assigned an invalid value:

Welcome to Node.js v22.9.0.
Type ".help" for more information.
> process.env.AWS_SESSION_TOKEN || process.env.AMAZON_SESSION_TOKEN
undefined
> process.env.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN || process.env.AMAZON_SESSION_TOKEN
undefined
> process.env.AWS_SESSION_TOKEN
'undefined'

Closes https://github.com/aws/aws-cdk/issues/32120.

Checklist


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

codecov[bot] commented 1 day ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 77.15%. Comparing base (339fed1) to head (eee2a95).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #32134 +/- ## ======================================= Coverage 77.14% 77.15% ======================================= Files 105 105 Lines 7163 7165 +2 Branches 1311 1312 +1 ======================================= + Hits 5526 5528 +2 Misses 1457 1457 Partials 180 180 ``` | [Flag](https://app.codecov.io/gh/aws/aws-cdk/pull/32134/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | Coverage Δ | | |---|---|---| | [suite.unit](https://app.codecov.io/gh/aws/aws-cdk/pull/32134/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | `77.15% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/aws/aws-cdk/pull/32134/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | Coverage Δ | | |---|---|---| | [packages/aws-cdk](https://app.codecov.io/gh/aws/aws-cdk/pull/32134/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | `77.15% <100.00%> (+<0.01%)` | :arrow_up: |
aws-cdk-automation commented 1 day ago

:arrow_right: PR build request submitted to test-main-pipeline :arrow_left:

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

mergify[bot] commented 1 day ago

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).

aws-cdk-automation commented 1 day ago

AWS CodeBuild CI Report

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

mergify[bot] commented 1 day ago

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).

github-actions[bot] commented 1 day ago

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.