Skip to content

Can't use a profile that used aws login for temporary credentials #3300

Description

@amcsi

Describe the bug

I would like to be able to use a profile configured automatically by the aws login CLI command, but I'm not able to, because the SDK seems to demand that whichever profile I use (or whichever profile is referenced as source_profile) must have aws_access_key_id and aws_secret_access_key.
And by the way running the AWS CLI with that same profile works, and I'm able to run this command fine, successfully: aws rds describe-db-instances --profile project-monitor.

AWS PHP SDK version: 3.384.7

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

It's expected to work and list the files. Just as if I had source_profile = default within [profile aszeremi-local]

php artisan tinker
Psy Shell v0.12.9 (PHP 8.4.21 — cli) by Justin Hileman
> Storage::drive('s3')->files()

[
    "SANDBOX-0283344D-8126-4530-A518-4F04378118AA.json",
    "SANDBOX-145880F2-B469-4D9A-A086-AE5AD126DECB.json",
]

Current Behavior

Running

php artisan tinker

This happens when I try to list the files:

Psy Shell v0.12.9 (PHP 8.4.21 — cli) by Justin Hileman
> Storage::drive('s3')->files()

   League\Flysystem\UnableToListContents  Unable to list contents for '', shallow listing

Reason: No credentials present in INI profile 'aszeremi-local' (/home/attila/.aws/credentials)

Reproduction Steps

This is what's in my ~/.aws/config:

[default]
aws_access_key_id = ...
aws_secret_access_key = ...

This is what was in my ~/.aws/config:

[profile project-monitor]
role_arn = arn:aws:iam::123456789012:role/project-monitor
source_profile = default
region = us-east-1

This is in my Laravel project's .env:

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SDK_LOAD_NONDEFAULT_CONFIG=1
AWS_PROFILE=project-monitor
AWS_DEFAULT_REGION=us-east-1
AWS_REGION=us-east-1

With this I am able to perform the AWS S3 task that I want.

But now I wanted to move away from using long-lived credentials locally...
So after running aws login --profile aszeremi-local and logging in, this got appended to ~/.aws/config:

[profile aszeremi-local]
login_session = arn:aws:iam::123456789012:user/aszeremi-local
region = us-east-1

So now I changed my project-monitor profile to use the new aszeremi-local profile as the source, so now this is my ~/.aws/config:

[profile project-monitor]
role_arn = arn:aws:iam::123456789012:role/project-monitor
source_profile = aszeremi-local # <- this is the change I made
region = us-east-1
[profile aszeremi-local]
login_session = arn:aws:iam::123456789012:user/aszeremi-local
region = us-east-1

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.384.7

Environment details (Version of PHP (php -v)? OS name and version, etc.)

PHP 8.4.21, Ubuntu 24.04

Metadata

Metadata

Assignees

Labels

guidanceQuestion that needs advice or information.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions