AWS Java 开发工具包在使用 AWS SSO 时找不到配置文件
使用 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。
然后我设置了变量:但是在java上,我得到了以下异常:AWS_PROFILE=staging
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,但结果是相同的。
我应该使用什么?CredentialsProvider
我的代码正在使用 DefaultProviderChain:
AWSGlueClient.builder()
.withRegion("eu-west-1")
.build()
谢谢。