question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serverless using AWS profiles only half working

See original GitHub issue

This is a Bug Report

Description

When using the serverless deploy --aws-profile or using the EXPORT AWS_PROFILE=<profile>; serverless deploy or the AWS_PROFILE=<profile> serverless deploy it only reads from the credentials file, but that should also be reading from the config file like the default aws cli tools does.

For example I have the following two files

~/.aws/config
[default]
aws_access_key_id = <>
aws_secret_access_key = <>

~/.aws/credentials
[profile default]
output = json
region = us-east-1

[profile dev]
role_arn = <cross_account_role>
source_profile = <another_profile>
mfa_serial = <mfa_serial>
region = us-east-1
output = json

If I run serverless deploy --profile dev it will fail with

ServerlessError: AWS provider credentials not found. You can find more info on how to set up provider credentials in our docs here: https://git.io/vXsdd

Then I tried AWS_PROFILE=dev serverless deploy and it failed with the above error

And finally I ran export AWS_PROFILE="dev" && export AWS_REGION=us-east-1 and then ran the serverless deploy and the same error occur.

So reading more in depth the above small link and talking to people on Gitter I moved that dev profile to ~/.aws/config, creating new keys since the previous used a cross account mfa role.

Its my experience using Troposphere and tools that rely on AWS Profiles, they should be looking into all of them and if they have an mfa, request the code about it.

Additional Data

  • Serverless Framework Version you’re using: 1.15.3
  • Operating System: Mac OS 10.12.5
  • Stack Trace: Shown above

Workaround

Create an additional profile and store it inside the ~/.aws/config to use and then you can refer to it using --profile <profile>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:61
  • Comments:73 (21 by maintainers)

github_iconTop GitHub Comments

67reactions
dougiretoncommented, May 17, 2018

You can use AWS Profiles with Severless, including IAM cross-account role assumption, if you set this environment variable:

export AWS_SDK_LOAD_CONFIG=1

This enables any tool which uses the AWS SDK for Go (e.g. Serverless framework) to use AWS Profiles.

16reactions
SkxNMDI5commented, Nov 25, 2017

Hi, You can make it work by using the right declaration style in your ~/.aws/credentials file :

[dev]
role_arn = <cross_account_role>
source_profile = <another_profile>
....

instead of :

[profile dev]
role_arn = <cross_account_role>
source_profile = <another_profile>
....
Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Credentials
AWS Credentials. The Serverless Framework needs access to your cloud provider account so that it can create and manage resources on your behalf....
Read more >
AWS profile doesn't seem to be configured! Serverless ...
This is a known issue with Serverless, Serverless only checks ~/.aws/credentials for the profile and not ~/.aws/config .
Read more >
Configure Multiple AWS Profiles
This is telling Serverless Framework to use the value from the --stage CLI option if it exists. If not, use the default stage...
Read more >
Named profiles for the AWS CLI
Create and use name profiles for AWS CLI commands. ... A named profile is a collection of settings and credentials that you can...
Read more >
Creating profiles for your AWS credentials
If the Regions that you're working with are not shown (for example, ... In this case, the default profile is an IAM user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found