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.

sam local start-api --profile option doesn't work with assumed role

See original GitHub issue

My ~/.aws/config looks like:

[profile default]
region = us-east-1
output = json
[profile admin@other]
region = us-east-1
role_arn = arn:aws:iam::123456789012:role/admin
source_profile = default

Specifying --profile admin@other shows a warning in the logs:

2017/12/01 12:12:43 WARNING: No AWS credentials found. Missing credentials may lead to slow startup times as detailed in https://github.com/awslabs/aws-sam-local/issues/134

As a workaround I made a “dev” IAM user and access keys in the “other” account , and configured another awscli profile with those keys. Then --profile dev@other works fine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
iphcommented, Dec 7, 2017

Interesting.

So, here’s my thought process so far:

Code where we initialize the session using options: https://github.com/awslabs/aws-sam-local/blob/develop/env.go#L128-L141 Godocs on session, search for: Shared Config Fields https://docs.aws.amazon.com/sdk-for-go/api/aws/session/

If the AWS_SDK_LOAD_CONFIG environment variable is set, or SharedConfigEnable option is used to create the Session the full shared config values will be loaded. This includes credentials, region, and support for assume role. In addition the Session will load its configuration from both the shared config file (~/.aws/config) and shared credentials file (~/.aws/credentials). Both files have the same format.

Maybe since we override with our own options, the value gets set to false by default and environment variables aren’t even attempted?

Gonna fiddle with that assumption a bit more.

0reactions
day2daychallengecommented, Nov 30, 2019

How to solve this issue in windows?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam local start-api --profile option doesn't work with ... - GitHub
As a workaround I made a "dev" IAM user and access keys in the "other" account , and configured another awscli profile with...
Read more >
sam local invoke - AWS Serverless Application Model
Invoke a local Lambda function using the sam local invoke command from the AWS SAM CLI.
Read more >
Can one develop locally with AWS SAM using a role?
Using sam local start-api it doesn't appear to correctly take on my exported $AWS_PROFILE via ~/.aws/credentials.
Read more >
AWS SAM Local Invoke with Lambda Role - Brian Pfeil
Allowing Our Lambda Role to be Assumed. In our scenario, we have a local user profile named admin stored in ~/.aws/credentials.
Read more >
AWS Lambda Testing and Debugging using IntelliJ, AWS ...
To solve this error, just go to File -> Settings -> Tools -> AWS and check if the path for SAM CLI executables...
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