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.

GetCallerIdentityAsync throws an exception when calling it from a docker container

See original GitHub issue

Hi,

In AWS CodeBuild, you have the ability to build your code in a Docker container. To propagate the credentials to your container, you need to pass few extra parameters:

docker build --build-arg AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION --build-arg AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI .

To validate this config, I ran aws sts get-caller-identity and got this response:

Step 9/31 : RUN aws sts get-caller-identity 
 ---> Running in 080c749553b9 
{ 
    "Account": "123456789",  
    "UserId": "AROXXXXXXX:AWSCodeBuild-(...)",  
    "Arn": "arn:aws:sts::123456789:assumed-role/codebuild-core-srv-pricing-service-role/AWSCodeBuild-(...)" 
}

When running sleet in this environment, I get the following exception:

[System.ArgumentException] Failed to determine AWS identity - ensure you have an IAM role set, have set up default credentials or have specified a profile/key pair.

Unfortunately we do no have much details regarding the exception raised by the AWS client. Would be great to add a exception.ToString() so we can troubleshoot.

I’m not sure why we are getting this error but wan we try adding a parameter called --inherit-permissions bypassing this check?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
serochecommented, Oct 4, 2019

Can confirm it’s working well when executing sleet in a docker container.

Don’t forget to include the following lines in your dockerfile:

# Build and deploy Domain NuGet packages
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-alpine3.9 AS base
ARG AWS_DEFAULT_REGION
ARG AWS_CONTAINER_CREDENTIALS_RELATIVE_URI

ENV AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
ENV AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION

Then call docker build: docker build --build-arg AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION --build-arg AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI .

1reaction
serochecommented, Oct 2, 2019

Let me have a look on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

net Core Console application in Docker Container throws ...
The Exception is thrown at this line in Program.cs: var dataStorage = _serviceProvider.GetService<IDataStorageService>();. In the Startup.cs the ...
Read more >
Dotnet inside Docker giving Connection Refused error
am running an API which I made using Dotnet Core and Swagger inside ... is at) the exception is not thrown and it...
Read more >
How to Fix and Debug Docker Containers Like a Superhero
Container errors are tricky to diagnose, but some investigative magic works wonders. Read along to learn how to debug Docker containers.
Read more >
Troubleshooting errors with Docker commands when using ...
In some cases, running a Docker command against Amazon ECR may result in an error message. Some common error messages and potential solutions...
Read more >
Runtime options with Memory, CPUs, and GPUs
On Linux hosts, if the kernel detects that there is not enough memory to perform important system functions, it throws an OOME ,...
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