Skip to content

Bug: No way to pass custom credentials/session vars to AWS Secrets Manager provider #3275

Description

@mrharpo

Summary

When the AWS Secrets Manager secrets provider needs to authenticate against a different AWS account/credentials than the default S3 datastore, there is no configuration to supply custom session variables or client parameters.

The S3 datatools client supports this via METAFLOW_DATATOOLS_SESSION_VARS / METAFLOW_DATATOOLS_CLIENT_PARAMS, but there is no equivalent METAFLOW_AWS_SECRETS_MANAGER_SESSION_VARS / METAFLOW_AWS_SECRETS_MANAGER_CLIENT_PARAMS.

Details

get_aws_client already accepts session_vars and client_params, and the S3 datatools path wires config values straight through:

def get_aws_client(
module, with_error=False, role_arn=None, session_vars=None, client_params=None
):

return cached_provider_class.get_client(
module,
with_error,
role_arn=role_arn,
session_vars=session_vars,
client_params=client_params,
)

The AWS Secrets Manager provider, however, only passes region_name and role_arn, leaving session_vars / client_params unset:

secrets_manager_client = get_aws_client(
"secretsmanager",
client_params={"region_name": effective_aws_region},
role_arn=role,
)

As a result there is no way to customize the botocore session/client for Secrets Manager (e.g. supplying a different profile, credential provider, or endpoint) when the secret lives in a different account/credential context than the S3 store.

The only available override is AWS_SECRETS_MANAGER_DEFAULT_ROLE (role assumption), which doesn't cover all credential scenarios, including ours.

Expected behavior

Provide config options comparable to the datatools ones, e.g. METAFLOW_AWS_SECRETS_MANAGER_SESSION_VARS and METAFLOW_AWS_SECRETS_MANAGER_CLIENT_PARAMS passed through to get_aws_client when the Secrets Manager provider builds its client, so custom credentials can be supplied via the environment/config.

Relevant files

Environment

Metaflow version: 2.19.33

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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