【发布时间】:2021-01-11 16:58:00
【问题描述】:
使用 AWS SSO 登录时,我无法访问 aws。 我使用以下方式从我的计算机登录:
aws sso login --profile staging
配置文件是这样配置的:
[profile staging]
sso_start_url = https://som-nice-working-url
sso_region = us-east-1
sso_account_id = 1234
sso_role_name = the-role-name
region = eu-west-1
output = yaml
登录后,我可以通过 aws cli 访问 aws。
然后我设置变量:AWS_PROFILE=staging
但是在 java 上我得到了以下异常:
com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), WebIdentityTokenCredentialsProvider: You must specify a value for roleArn and roleSessionName, com.amazonaws.auth.profile.ProfileCredentialsProvider@369a95a5: No AWS profile named 'staging', com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@6d6f6ca9: Failed to connect to service endpoint: ]
我已尝试将 ProfileCredentialsProvider 与“staging”一起使用,但结果是一样的。
我应该使用什么CredentialsProvider?
我的代码正在使用 DefaultProviderChain:
AWSGlueClient.builder()
.withRegion("eu-west-1")
.build()
谢谢。
【问题讨论】:
标签: java amazon-web-services sdk single-sign-on