Update 2021-07-09:
- Invested a bit more time for testing and narrowed the problem to AWS CDK and NOT AWS CLI.
- If I run
aws s3 ls --profile dev
a cache file is created under~/.aws/cli/cache/<random_hash>
and everything is working. So my question was misleading so far, as I never tested without CDK. I always usedcdk synth --profile dev
or another CDK command. - Therefore, can you help in regards with CDK? Why is not behaving as the CLI itself?
Update 2021-07-09 +10min:
- I found the following issue, and therefore close this question as it seems to be the mentioned.
I follow the advice from here and use the ~/.aws/config file to incorporate MFA in my authentication flow. The role (in 123456789123) has a maximum session duration of one hour, but still I'm prompted for an MFA token every time I run a command. How can I temporarily store the authentication and run a command without MFA interruption? I do not want to circumvent the MFA but store the sts-session for the configured hour - to at least work without interruption for this hour.
~/.aws/config
[default]
region = eu-central-1
[profile dev]
role_arn = arn:aws:iam::123456789123:role/my_admin_role
source_profile = corporation
mfa_serial = arn:aws:iam::023456789123:mfa/my_iam_user
~/.aws/credentials
[corporation]
aws_access_key_id = BLIBLABLUB
aws_secret_access_key = BLIBLABLUB