为awscrt.auth.AwsCredentialsProvider指定配置文件 [英] Specifying a profile for awscrt.auth.AwsCredentialsProvider
问题描述
我正在创建一个 AwsCredentialsProvider
类(
I'm creating an AwsCredentialsProvider
class (api docs) from:
awscrt.auth.AwsCredentialsProvider.new_default_chain(client_bootstrap)
我收到错误 AWS_ERROR_MQTT_UNEXPECTED_HANGUP
,我认为这是因为我的AWS凭证位于〜/.aws/credentials
(基于此git问题).
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).
但是我看不到用指定的配置文件创建 AwsCredentialsProvider
的任何方法.
But I can't see any way to create an AwsCredentialsProvider
with a specified profile.
推荐答案
对于自定义凭据文件路径,请设置环境变量 AWS_CONFIG_FILE
和 AWS_CREDENTIAL_FILE
For custom credentials file path set environment variables AWS_CONFIG_FILE
and AWS_CREDENTIAL_FILE
对于具有默认配置文件名称的环境变量 AWS_PROFILE
,您希望将其选择为AWS配置文件名称.为了在运行时使用,此AWS配置文件名称必须以有效的配置显示在您的AWS凭证文件中.
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.
如果仅使用一个AWS区域,则还可以设置环境变量 AWS_DEFAULT_REGION
.有时它会保存几行代码,您可能需要在其中指定一个AWS区域.
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.
这篇关于为awscrt.auth.AwsCredentialsProvider指定配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!