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(cli): can't use credential providers for stacks with assets #7022

Merged
merged 3 commits into from
Mar 26, 2020

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 26, 2020

Stacks with assets were broken for environments that completely
used credential providers (and no other sources of AWS credentials).

Not because the wrong credentials were being used (as you would expect
it to be broken). Instead, an error was being thrown because the
"current" account lookup was incorrectly forwarding to the "default"
account lookup (fix: we know what the current account is. Just return
that instead).

What's worse, this value wasn't even being used! It was being looked up
so that if something was wrong finding the target bucket, we could
format a nice error message containing the account id. Even happy
paths were failing due to the premature lookup though (fix: only
look up when we actually need the value).

Fixes #7005.


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

Stacks with assets were broken for environments that completely
used credential providers (and no other sources of AWS credentials).

Not because the wrong credentials were being used (as you would expect
it to be broken). Instead, an error was being thrown because the
"current" account lookup was incorrectly forwarding to the "default"
account lookup (fix: we know what the current account is. Just return
that instead).

What's worse, this value wasn't even being used! It was being looked up
so that if something was wrong finding the target bucket, we could
format a nice error message containing the account id. Even happy
paths were failing due to the premature lookup though (fix: only
look up when we actually need the value).

Fixes #7005.
@rix0rrr rix0rrr requested a review from a team March 26, 2020 12:41
@rix0rrr rix0rrr self-assigned this Mar 26, 2020
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 26, 2020
// don't have "default" credentials, (such as when we're using a
// CredentialProvider), then we'll just guess the partition to be 'aws'. Our
// credential provider protocol currently doesn't provide for partition
// information.
const account = await this.aws.defaultAccount();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be based on this.targetEnv.account instead of defaultAccount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should. I was making a simplification with a plan to fix it later. But we could just take the current configuration to look up the partition anyway.

It'll be less efficient but more correct.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 508094d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@rix0rrr rix0rrr requested a review from eladb March 26, 2020 13:59
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 156d60c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Mar 26, 2020

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 26, 2020

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: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 25477bb
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Mar 26, 2020

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 26, 2020

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

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdk-assets does not honour plugins of type CredentialProviderSource
3 participants