amazon-web-servicesaws-iotaws-credentials

Specifying a profile for awscrt.auth.AwsCredentialsProvider


I'm creating an AwsCredentialsProvider class (api docs) from:

awscrt.auth.AwsCredentialsProvider.new_default_chain(client_bootstrap)

I get an error AWS_ERROR_MQTT_UNEXPECTED_HANGUP which I believe occurs because my AWS credentials are under a non default profile in ~/.aws/credentials (based on this git issue).

But I can't see any way to create an AwsCredentialsProvider with a specified profile.


Solution

  • For custom credentials file path set environment variables AWS_CONFIG_FILE and AWS_CREDENTIAL_FILE

    For default profile set environment variable AWS_PROFILE with AWS profile name you would like to select as default. In order to use at runtime, this AWS profile name must be present in your AWS credentials file with valid configurations.

    If you use only one AWS region, then you can also set environment variable AWS_DEFAULT_REGION. At times it saves few lines of code, where you might need to specify a AWS region.