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): CLI ignores profile in cdk.json #7398

Merged
merged 2 commits into from
Apr 29, 2020
Merged

fix(cli): CLI ignores profile in cdk.json #7398

merged 2 commits into from
Apr 29, 2020

Conversation

itoyama
Copy link
Contributor

@itoyama itoyama commented Apr 17, 2020

validation steps

  • Prepare that the command like cdk diff $SOME_STACK_NAME --profile $SOME_PROFILE_NAME succeeds
  • Execute cdk diff $SOME_STACK_NAME and receive failures to confirm no credential is implicitly provided.
  • Add "profile": "$SOME_PROFILE_NAME" to cdk.json. Execute cdk diff $SOME_STACK_NAME and it must finish successfully.

Commit Message

fix(cli): CLI ignores profile in cdk.json (#7398)

The profile option was not being passed from cdk.json.

Get the values from the merged configuration, instead of using the profile argument directly.

Closes #3007

End Commit Message


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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 6142a5b
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3408216
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@itoyama itoyama changed the title fix(cli): CLI ignores profile in cdk.json chore(cli): CLI ignores profile in cdk.json Apr 17, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

@shivlaks shivlaks left a comment

Choose a reason for hiding this comment

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

nice!

This should be tagged as a fix as it's resolving a bug and not as a chore. Can you modify the title and also add corresponding tests.

@itoyama
Copy link
Contributor Author

itoyama commented Apr 21, 2020

This test should be an integration test. However, the integration testing requires that I actually generate the stack on AWS. I don't have a personal AWS account, so I cannot develop.

If you want me to create a unit test, that involves refactoring of initCommandLine() @ packages/aws-cdk/bin/cdk.ts. The functions in the initCommandLine function should be split to make them unit-testable. This is so huge task and beyond my control.

@shivlaks
Copy link
Contributor

@itoyama - It's a straightforward enough change and I agree that the scope of this change isn't to make this module more testable.

can you include any validation steps you've done on this change in the commit body?

@itoyama
Copy link
Contributor Author

itoyama commented Apr 21, 2020

how was this tested?

This is Indirectly tested by my company's AWS account during my work.

can you include any validation steps you've done on this change in the commit body?

OK I will add.

@itoyama
Copy link
Contributor Author

itoyama commented Apr 21, 2020

@shivlaks Is the following explanation sufficient?


validation steps

  • Prepare that the command like cdk diff $SOME_STACK_NAME --profile $SOME_PROFILE_NAME succeeds
  • Execute cdk diff $SOME_STACK_NAME and receive failures to confirm no credential is implicitly provided.
  • Add "profile": "$SOME_PROFILE_NAME" to cdk.json. Execute cdk diff $SOME_STACK_NAME and it must finish successfully.

@shivlaks shivlaks changed the title chore(cli): CLI ignores profile in cdk.json fix(cli): CLI ignores profile in cdk.json Apr 22, 2020
const sdkProvider = await SdkProvider.withAwsCliCompatibleDefaults({
profile: argv.profile,
profile: configuration.settings.get(['profile']),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to write code in Configuration to copy argv.profile into itself.

It's not as automatic as you would expect (iirc).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code is added to L196 because L218 is in the function for parsing 'context' values.

Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

See comment

@mergify mergify bot dismissed stale reviews from shivlaks and rix0rrr April 27, 2020 07:33

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@itoyama
Copy link
Contributor Author

itoyama commented Apr 27, 2020

Validated via docker:

docker run -v ${YOUR_CDK_PROJECT_DIR}:/proj -v ${HOME}/.aws:/root/.aws -w /proj aws-cdk diff ${YOUR_STACK_NAME}

Also using command line argument:

docker run -v ${YOUR_CDK_PROJECT_DIR}:/proj -v ${HOME}/.aws:/root/.aws -w /proj aws-cdk diff ${YOUR_STACK_NAME} --profile ${YOUR_AWS_PROFILE_NAME}

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

The profile option was not being passed from cdk.json.

Get the values from the merged configuration, instead of using the profile argument directly.

Validation steps:

* Prepare that the command like `cdk diff $SOME_STACK_NAME --profile $SOME_PROFILE_NAME` succeeds
* Execute `cdk diff $SOME_STACK_NAME` and receive failures to confirm no credential is implicitly provided.
* Add "profile": "$SOME_PROFILE_NAME" to cdk.json. Execute `cdk diff $SOME_STACK_NAME` and it must finish successfully.

Fixes #3007
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@rix0rrr rix0rrr added the pr-linter/exempt-test The PR linter will not require test changes label Apr 28, 2020
@mergify
Copy link
Contributor

mergify bot commented Apr 29, 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: cc35631
  • 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 Apr 29, 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).

@mergify mergify bot merged commit 6784dc3 into aws:master Apr 29, 2020
@itoyama itoyama deleted the feature/3007-profile-from-cdk-json branch April 29, 2020 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

CLI ignores profile in cdk.json
4 participants