Summary
The AWS plugin cannot authenticate when the configured AWS profile is a chained assume-role that requires MFA. The agent's AWS SDK config load fails because no AssumeRoleTokenProvider is wired up, so the SDK has no way to obtain the MFA token non-interactively.
Environment
- formae
0.83.2 (local agent, SQLite datastore), macOS arm64
- AWS resource plugin
aws@0.1.4
- AWS CLI v2 present on the host
What happens
With a target that resolves to an MFA/assume-role profile, discovery and apply spam errors like:
ERR Failed to list resources for AWS::S3::AccessPoint in target default-aws-target:
loading AWS config: assume role with MFA enabled, but AssumeRoleTokenProvider session option not set.
Every resource type fails the same way, so nothing can be discovered or applied.
Repro
~/.aws/config with a chained, MFA-gated role (names generalized):
[profile base]
# static creds or SSO
[profile base-mfa-role]
role_arn = arn:aws:iam::<acct-a>:role/devops-role
mfa_serial = arn:aws:iam::<acct-a>:mfa/<device>
source_profile = base
[profile dev-role]
role_arn = arn:aws:iam::<acct-b>:role/devops-role
source_profile = base-mfa-role
Forma target:
config = new aws.Config {
region = "us-west-2"
profile = "dev-role"
}
Start the agent and apply/discover → the error above.
Root cause
The agent loads AWS config with the profile but does not register a token provider (config.WithAssumeRoleCredentialOptions / stscreds.AssumeRoleOptions.TokenProvider). The Go SDK therefore cannot satisfy the mfa_serial requirement. Notably, the agent also does not read the AWS CLI's assume-role cache (~/.aws/cli/cache), so authenticating via the CLI first does not help either.
Things that do not fix it:
aws sso login / pre-authenticating the profile in another shell (the SDK still tries to assume the role itself).
- Setting
AWS_PROFILE — with a profile set, the SDK re-enters the MFA chain and ignores static env creds.
Workaround
Let the AWS CLI resolve the chain (it prompts for MFA and caches), export the resulting temporary credentials as env vars, and start the agent in that shell. Do not pin profile in the forma (a pinned profile re-enters the MFA chain and ignores the env creds):
unset AWS_PROFILE AWS_DEFAULT_PROFILE
eval "$(aws configure export-credentials --profile dev-role --format env)"
formae agent start
Set only region in the target config. The exported session is temporary (~1h); re-export and restart when it expires.
Suggested fix
Any of:
- Register an
AssumeRoleTokenProvider (e.g. stscreds.StdinTokenProvider) when loading AWS config so interactive MFA works for local agents.
- Honor the AWS CLI assume-role cache (
~/.aws/cli/cache) / credential_process.
- Document the temporary-credentials workaround in the AWS plugin credentials section, and note that
profile should be omitted when supplying creds via env.
Summary
The AWS plugin cannot authenticate when the configured AWS profile is a chained assume-role that requires MFA. The agent's AWS SDK config load fails because no
AssumeRoleTokenProvideris wired up, so the SDK has no way to obtain the MFA token non-interactively.Environment
0.83.2(local agent, SQLite datastore), macOS arm64aws@0.1.4What happens
With a target that resolves to an MFA/assume-role profile, discovery and apply spam errors like:
Every resource type fails the same way, so nothing can be discovered or applied.
Repro
~/.aws/configwith a chained, MFA-gated role (names generalized):Forma target:
Start the agent and apply/discover → the error above.
Root cause
The agent loads AWS config with the profile but does not register a token provider (
config.WithAssumeRoleCredentialOptions/stscreds.AssumeRoleOptions.TokenProvider). The Go SDK therefore cannot satisfy themfa_serialrequirement. Notably, the agent also does not read the AWS CLI's assume-role cache (~/.aws/cli/cache), so authenticating via the CLI first does not help either.Things that do not fix it:
aws sso login/ pre-authenticating the profile in another shell (the SDK still tries to assume the role itself).AWS_PROFILE— with a profile set, the SDK re-enters the MFA chain and ignores static env creds.Workaround
Let the AWS CLI resolve the chain (it prompts for MFA and caches), export the resulting temporary credentials as env vars, and start the agent in that shell. Do not pin
profilein the forma (a pinned profile re-enters the MFA chain and ignores the env creds):Set only
regionin the target config. The exported session is temporary (~1h); re-export and restart when it expires.Suggested fix
Any of:
AssumeRoleTokenProvider(e.g.stscreds.StdinTokenProvider) when loading AWS config so interactive MFA works for local agents.~/.aws/cli/cache) /credential_process.profileshould be omitted when supplying creds via env.