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

feat(cli): support SSO #19454

Merged
merged 28 commits into from
Mar 21, 2022
Merged

feat(cli): support SSO #19454

merged 28 commits into from
Mar 21, 2022

Conversation

comcalvi
Copy link
Contributor

Adds support for SSO.


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

@comcalvi comcalvi requested a review from rix0rrr March 17, 2022 23:25
@gitpod-io
Copy link

gitpod-io bot commented Mar 17, 2022

@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Mar 17, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 17, 2022
@comcalvi comcalvi mentioned this pull request Mar 17, 2022
@comcalvi comcalvi added the pr-linter/exempt-test The PR linter will not require test changes label Mar 18, 2022
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Mar 18, 2022
await forceSdkToReadConfigIfPresent();
sources.push(() => new AWS.SsoCredentials({ profile: implicitProfile }));
}

if (await fs.pathExists(credentialsFileName())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try it without this if, and putting the SsoCredentials inside the sources array below?

Copy link
Contributor Author

@comcalvi comcalvi Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rix0rrr yep, this change works, with both an existing (but empty) credentials file and with no credentials file. Removing the config file breaks it, but that's expected. I also had to change one of the tests to use the 5th member of the chain instead of the 2nd (see diff), but this should be fine because that test seems to check for existence only.

@@ -3241,6 +3241,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

----------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want Eli to have a look at this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but looks like the aws-sdk upgrade in the CLI package broke the hoisting.

Currently on master we have:

<repoRoot>/node_modules/aws-sdk (version 2.1094.0)

When I upgraded aws-sdk@^2.979.0 to aws-sdk@^2.1093.0 and ran yarn install, I got the following directory structure:

<repoRoot>/node_modules/aws-sdk (version 2.1094.0)
<repoRoot>/packages/aws-cdk/node_modules/aws-sdk (version 2.1096.0)

I expected version 2.1096.0 to be hoisted and replace 2.1094.0 - but thats not what happens.

So in practice the CLI uses two different versions of aws-sdk. One coming from its own direct dependency, which isn't hoisted anymore (2.1096.0), and one coming transitively from cdk-assets, which is hoisted (2.1094.0).

We need to figure out why yarn isn't hoisting it. @rix0rrr Any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, feels like it should be able to. Wonder if there's a constraint somewhere that's preventing the hoist?

// Force reading the `config` file if it exists by setting the appropriate
// environment variable.
await forceSdkToReadConfigIfPresent();
sources.push(() => profileCredentials(implicitProfile));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the list of sources is duplicated in two places in the code. Maybe find a way to reuse?

@rix0rrr rix0rrr added pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr/do-not-merge This PR should not be merged at this time. labels Mar 21, 2022
@mergify
Copy link
Contributor

mergify bot commented Mar 21, 2022

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

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Mar 21, 2022

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: d61de2b
  • 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 eba6052 into aws:master Mar 21, 2022
@mergify
Copy link
Contributor

mergify bot commented Mar 21, 2022

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


function iniFileCredentialFactories(theProfile: string) {
return [
() => profileCredentials(theProfile),
Copy link

@pgrzesik pgrzesik May 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @comcalvi, is there a reason why credentials from the profile would take precedence here over the SSO? It's different than e.g. behavior of JS SDK v3 - https://github.com/aws/aws-sdk-js-v3/blob/31e72ac6063fdb3393c2d5042b8964238ce1b23a/packages/credential-provider-node/src/defaultProvider.ts#L52-L54

Or am I missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. package/tools Related to AWS CDK Tools or CLI pr-linter/exempt-integ-test The PR linter will not require integ test 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.

6 participants