Repository: starship/starship
File: src/modules/aws.rs (Rust)

Code before:
        .take_while(|line| !line.starts_with('['))
        .find(|line| line.starts_with("aws_access_key_id"))?;
    let aws_key_id = aws_key_id_line.split('=').nth(1)?.trim();
    Some(aws_key_id.to_string())
}

pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let mut module = context.new_module("aws");
    let config: AwsConfig = AwsConfig::try_load(module.config);

    let (aws_profile, aws_region) = get_aws_profile_and_region(context);
    if aws_profile.is_none() && aws_region.is_none() {
        return None;
    }

    // only display if credential_process is defined or has valid credentials
    if get_credential_process(context, aws_profile.as_ref()).is_none()
        && get_defined_credentials(context, aws_profile.as_ref()).is_none()
    {
        return None;
    }

    let mapped_region = if let Some(aws_region) = aws_region {
        Some(alias_region(aws_region, &config.region_aliases))
    } else {
        None
    };

    let duration = {
        get_credentials_duration(context, aws_profile.as_ref()).map(|duration| {
            if duration > 0 {
                render_time((duration * 1000) as u128, false)
            } else {
                config.expiration_symbol.to_string()
            }
        })
    };

    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|variable, _| match variable {
                "symbol" => Some(config.symbol),
                _ => None,
            })
            .map_style(|variable| match variable {
                "style" => Some(Ok(config.style)),
                _ => None,
            })
            .map(|variable| match variable {
                "profile" => aws_profile.as_ref().map(Ok),
                "region" => mapped_region.as_ref().map(Ok),

Review comment (security):
Should we also support the [environment variable](https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-credential_process.html) e.g `AWS_SECRET_ACCESS_KEY` and `AWS_SESSION_TOKEN`? 

Code after:
    let profile_line = if let Some(aws_profile) = aws_profile {
        format!("[{}]", aws_profile)
    } else {
        "[default]".to_string()
    };

    let aws_key_id_line = contents
        .lines()
        .skip_while(|line| line != &profile_line)
        .skip(1)
        .take_while(|line| !line.starts_with('['))
        .find(|line| line.starts_with("aws_access_key_id"))?;
    let aws_key_id = aws_key_id_line.split('=').nth(1)?.trim();
    Some(aws_key_id.to_string())
}

pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
    let mut module = context.new_module("aws");
    let config: AwsConfig = AwsConfig::try_load(module.config);

    let (aws_profile, aws_region) = get_aws_profile_and_region(context);
    if aws_profile.is_none() && aws_region.is_none() {
        return None;
    }

    // only display if credential_process is defined or has valid credentials
    if get_credential_process(context, aws_profile.as_ref()).is_none()
        && get_defined_credentials(context, aws_profile.as_ref()).is_none()
    {
        return None;
    }

    let mapped_region = if let Some(aws_region) = aws_region {
        Some(alias_region(aws_region, &config.region_aliases))
    } else {
        None
    };

    let duration = {
        get_credentials_duration(context, aws_profile.as_ref()).map(|duration| {
            if duration > 0 {
                render_time((duration * 1000) as u128, false)
            } else {
                config.expiration_symbol.to_string()
            }
        })
    };

    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|variable, _| match variable {