Aws-cdk: Error message not good enough in case only region is not defined

Created on 19 Jun 2018  路  14Comments  路  Source: aws/aws-cdk

Repro:

  1. Clean up ~/.aws/config, ~/.aws/credentials and any environment variables.
  2. Run aws configure, supply access key and secret, but leave "region" to None.

Then, try to run cdk delpoy. The error message is:

Stack hello-cdk does not define an environment, and AWS credentails could not be obtained from standard locations.

Also, there's a typo "credentails" :wink:

feature-request

Most helpful comment

Can you try to set AWS_REGION=us-east-1 and see if this helps?

Yes, this worked. Thanks!

All 14 comments

Alright the typo is an easy fix. As per the error message, I see the problem... I'm afraid this gets into rather verbose messaging though, what I'm inclined to use now is:

Stack ${stack.name} does not define an environment, and AWS credentials could not be obtained from standard locations or no region was configured.

It feels both verbose and barely actionable, which makes me unhappy. I'd appreciate any suggestion for a better wording. I was for one thing thinking about pointing the user to the documentation page of the AWS SDK/CLI on how to configure credentials/region, too.

I have no problem with verbosity in error messages. If it will help users identify what went wrong and how to fix it, it should be in the message.

Point them to the "Getting Started" topic. It has a link to the CLI command and reinforces them to read the d@mn docs!

:wave: I'm taking my first baby steps beta testing the CDK today and I'm a bit stuck here. When running cdk deploy I get the error message that's under discussion above.

I have the following AWS credentials and configurations in environment variables:

$ printenv | grep AWS_
AWS_CREDENTIAL_EXPIRATION=2018-06-21T23:38:44.000Z
AWS_SESSION_TOKEN=xxx
AWS_SECRET_ACCESS_KEY=xxx
AWS_ACCESS_KEY_ID=xxx
AWS_ACCOUNT_ID=123456789012
AWS_DEFAULT_REGION=us-east-1

My organization sticks to environment variables, and uses temporary credentials at all times -- the awscli configure command is not a good fit for our workflows. Is there something missing in my environment that the CDK needs in order to get a deploy to work?

Hey @rclark - according to the AWS SDK for JS documentation, AWS_DEFAULT_REGION is not considered, only AWS_REGIONis. Can you try to set AWS_REGION=us-east-1 and see if this helps?

Did we remove support for AWS_DEFAULT_REGION? Because I definitely implemented that at the toolkit level at some point, taking boto3 and AWS CLI as a reference point.

I feel that since this is what the AWS CLI expects, and people will have written tooling to generate those environment variables, we should support that.

I guess it was dropped when we adopted "pure SDK" behavior. We can re-introduce, obviously, however I would rather get the JS SDK fixed so it behaves like the other SDKs...

I found aws/aws-sdk-js#373 on this particular topic. It would appear the CLI (and boto) are outliers compared to the other SDKs. What I propose is to amend our own code so that:

  • If AWS_DEFAULT_PROFILE is set and AWS_PROFILE is not, set AWS_PROFILE to what AWS_DEFAULT_PROFILE is.
  • If AWS_DEFAUL_REGION is set and AWS_REGION is not, set AWS_REGION to what AWS_DEFAULT_REGION is.

Then continue using the JS SDK for determining region, account, ....

We need to document:

  • The environment values we recognize
  • Our credentials/config (region) lookup order

Can you try to set AWS_REGION=us-east-1 and see if this helps?

Yes, this worked. Thanks!

I think we should align our behavior to the CLI, with all it's beautiful outlying quirks because the toolkit is a command-line-tool and user expectation would be for it to behave similarly to the CLI

@RomainMuller I think your proposal makes sense.

Submitted #175 to implement that suggestion.

175 resolves this

Was this page helpful?
0 / 5 - 0 ratings