Aws-cli can't find aws config

Hi There,

AWS CLI can’t find config file.

I have a Jenkins controller running in AWS ECS and the slaves. All the data stored in aws EFS including .aws/ folder.
As far as I can tell efs mapping is correct. When I run cd / ls command on a pipeline I can see the files in:


And I am sure what I have in “config” is correct because it’s working when I am using a static EC2 node. e.g

[profile MYPROFILE]
role_arn = arn:aws:iam::0101010101:role/xxxxx-xxxx-apss-use1-jenkinsDeployment-Role
credential_source = Ec2InstanceMetadata

Agent can read config file “cat /home/jenkins/.aws/config”

Also the instance profile attached to agent containers.

I have tried passing aws config location with ENV when I built agent container.

ENV AWS_CONFIG_FILE=/home/jenkins/.aws/config

The error message is:

Error when retrieving credentials from Ec2InstanceMetadata: No credentials found in credential_source referenced in profile MYPROFILE

Also tried to store/map creds to /root/.aws

Jenkins master Version 2.440.2
Agent container built FROM jenkins/inbound-agent:latest

+ aws --version
aws-cli/2.9.19 Python/3.11.2 Linux/5.10.210-201.852.amzn2.x86_64 exec-env/AWS_ECS_FARGATE source/x86_64.debian.12 prompt/off

Thank you in advance.

It wasn’t that aws cli can’t find the config file it was config file itself.

[profile MYPROFILE]
role_arn = arn:aws:iam::010101010:role/xxx-jenkinsDeployment-Role
credential_source = Ec2InstanceMetadata

replace Ec2InstanceMetadata with EcsContainer worked.