amazon-archives / awsmobile-cli

CLI experience for Frontend developers in the JavaScript ecosystem.
Apache License 2.0
142 stars 35 forks source link

Add profile support for profiles stored in ~/.aws/credentials #98

Closed matsev closed 6 years ago

matsev commented 6 years ago

AWS CLI profiles stored in the ~/.aws/credentials file are not recognised by awsmobile-cli when calling

$ awsmobile configure aws --profile MY_AWS_MOBILE_PROFILE

Expected result

awsmobile-cli should be configured with MY_AWS_MOBILE_PROFILE.

Actual result

$ awsmobile configure aws --profile MY_AWS_MOBILE_PROFILE

configure aws
Setting awsmobile-cli to use named profile: MY_AWS_MOBILE_PROFILE

profile MY_AWS_MOBILE_PROFILE is not found in aws-cli config file
aws-cli config file queried:
/Users/mattias/.aws/config

Failed to set profile MY_AWS_MOBILE_PROFILE

For the record, the contents of ~/.aws/credentials looks something like

[default]
aws_access_key_id = SOMEACCESSKEYID
aws_secret_access_key = SOME+SECRET+ACCESS+KEY

[MY_AWS_MOBILE_PROFILE]
aws_access_key_id = ANOTHERACCESSKEYID
aws_secret_access_key = ANOTHER+SECRET+ACCESS+KEY

awsmobile-cli version:

$ awsmobile --version
1.0.21

Relates to #48

UnleashedMind commented 6 years ago

The awsmobile-cli configuration needs both the credential key and the region. The aws cli stores the region configuration inside the ~/.aws/config file, if the awsmobile-cli can not find the region for the profile, it won't be able to complete the configuration, that's why you saw the error. Please add that profile inside the config file, and it should be fine. below is the example, please note that in this file, you need to add the word 'profile' before the profile name.

[profile MY_AWS_MOBILE_PROFILE] region = us-west-2

matsev commented 6 years ago

Thanks, that solved the problem. May I suggest that you update the error message to reflect this?

UnleashedMind commented 6 years ago

Thanks for your feedbacks. We will keep improving the cli user experience for our customers.