When using an IAM profile/role that requires multi-factor authentication in the AWS_PROFILE envar, the CDK CLI is not prompting for the MFA code, resulting in a missing credentials error.
[09:26:47] Error: Need to perform AWS calls for account ***, but no credentials have been configured
Regression Issue
[X] Select this option if this issue appears to be a regression.
Last Known Working CDK Version
2.166
Expected Behavior
The CDK CLI should prompt for a MFA code when a profile that requires MFA is set in the AWS_PROFILE envar
Current Behavior
The CDK CLI is unable to prompt because it does not have a MFA callback handler:
[09:49:12] Resolving default credentials
[09:49:12] Unable to determine the default AWS account (CredentialsProviderError): Profile *** requires multi-factor authentication, but no MFA code callback was provided.
Reproduction Steps
in ~/.aws/.config, create a profile that requires MFA
> cdk bootstrap
⏳ Bootstrapping environment aws://***/us-east-1...
❌ Environment aws://***/us-east-1 failed bootstrapping: Error: Need to perform AWS calls for account ***, but no credentials have been configured
Possible Solution
No response
Additional Information/Context
passing the --profile argument to the CDK CLI does prompt for MFA credentials
> cdk bootstrap --profile=infra
MFA token for arn:aws:iam::***:mfa/***:
The logs when using --profile
[10:29:07] Resolving default credentials
[10:29:07] Require MFA token for serial ARN arn:aws:iam::***:mfa/***
vs. logs when using AWS_PROFILE
[09:49:12] Resolving default credentials
[09:49:12] Unable to determine the default AWS account (CredentialsProviderError): Profile *** requires multi-factor authentication, but no MFA code callback was provided.
when using AWS_PROFILE the log message does identify the correct profile
Describe the bug
When using an IAM profile/role that requires multi-factor authentication in the
AWS_PROFILE
envar, the CDK CLI is not prompting for the MFA code, resulting in a missing credentials error.Regression Issue
Last Known Working CDK Version
2.166
Expected Behavior
The CDK CLI should prompt for a MFA code when a profile that requires MFA is set in the
AWS_PROFILE
envarCurrent Behavior
The CDK CLI is unable to prompt because it does not have a MFA callback handler:
Reproduction Steps
in
~/.aws/.config
, create a profile that requires MFAthen export that profile to the
AWS_PROFILE
envarnow run any cdk command that performs AWS calls:
Possible Solution
No response
Additional Information/Context
passing the
--profile
argument to the CDK CLI does prompt for MFA credentialsThe logs when using
--profile
vs. logs when using
AWS_PROFILE
when using
AWS_PROFILE
the log message does identify the correct profileCDK CLI Version
2.171.0 (build 4957967)
Framework Version
No response
Node.js Version
v20.12.2
OS
MacOS
Language
TypeScript
Language Version
No response
Other information
No response