0

我有一个在 EKS 中运行的应用程序实例,并设置了以下变量:

declare -x AWS_DEFAULT_REGION="us-west-2"
declare -x AWS_REGION="us-west-2"
declare -x AWS_ROLE_ARN="xxxxx"
declare -x AWS_WEB_IDENTITY_TOKEN_FILE="/var/run/secrets/eks.amazonaws.com/serviceaccount/token"

据我了解,有一个默认的 Java SDK 授权链,其中包含com.amazonaws.auth.WebIdentityTokenCredentialsProvider在后台构建com.amazonaws.services.securitytoken.AWSSecurityTokenService的内容。

但我无法意识到这种循环依赖是如何解决的?我的意思是您需要在创建过程中指定凭据,AWSSecurityTokenService但凭据会创建服务本身。

我有这样做的实际要求,我想在 sts 客户端中自定义端点,但由于循环依赖而不能。

AWSSecurityTokenServiceClientBuilder.standard()
        .withCredentials(new STSAssumeRoleWithWebIdentitySessionCredentialsProvider.Builder(
                "arn",
                "session",
                "tokenfile")
                .withStsClient(xxxx)
                .build())
        .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:4566", null))
        .build()
4

1 回答 1

0

很容易。它只是通过匿名身份验证完成(https://github.com/aws/aws-sdk-java/blob/1.11.792/aws-java-sdk-sts/src/main/java/com/amazonaws/auth/STSAssumeRoleWithWebIdentitySessionCredentialsProvider .java#L122-L125 )

        return AWSSecurityTokenServiceClientBuilder.standard()
                                                   .withClientConfiguration(clientConfiguration)
                                                   .withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
                                                   .build();
于 2021-05-14T12:49:47.827 回答