def METHOD_NAME(region, credential_arg):
    """Set the AWS credentials in the environment for the duration of the context."""
    credentials_config = _parse_credential_arg(credential_arg)
    if region in credentials_config:
        credential_endpoint, credential_arn, credential_external_id = credentials_config.get(region)
        with sts_credential_provider(region, credential_arn, credential_external_id, credential_endpoint):
            yield
    else:
        # Default to configured credentials
        logging.info("Using default AWS credentials")
        yield