Skip to main content

parse_aws_config_files

Function parse_aws_config_files 

Source
pub fn parse_aws_config_files(
    creds_path: &Path,
    config_path: &Path,
) -> Result<Vec<AwsConfigEntry>, AppError>
Expand description

Parse explicit credentials and config file paths into a list of AWS profiles.

This is the pure, testable surface. Pass fixture paths in tests; use discover_aws_profiles in production to resolve the real ~/.aws/* paths.

Merge rules:

  • Each unique profile name yields one AwsConfigEntry.
  • Secret fields (access_key_id, secret_access_key, session_token) always come from the credentials file.
  • Non-secret fields (region, role_arn, source_profile, …) come from the config file when present, falling back to the credentials file.
  • source is Credentials when only the credentials file has the profile, Config when only the config file has it, and Credentials (primary) when both files contribute fields (secrets always come from credentials).

Environment variable injection is handled by discover_aws_profiles so this function remains pure and does not read std::env.