com.amazonaws.Исключение SdkClientException : не удается выполнить HTTP-запрос: sts.amazonaws.com в GetSessionToken

#java #amazon-web-services #amazon-s3 #aws-sts

#java #amazon-веб-сервисы #amazon-s3 #aws-sts

Вопрос:

Не найдена точная первопричина. Это происходит во время выполнения GetSessionToken и его непоследовательного поведения. Может ли кто-нибудь знать основную причину и возможные исправления?

aws-java-sdk версии 1.11.905

Выполняемый код

 AWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, accessKeySecret);
AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder
                                    .standard()
                                    .withRegion("us-west-2") 
                                    .withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
                                    .build();
// Start a new session for managing a service instance's bucket 
GetSessionTokenRequest getSessionTokenRequest = new GetSessionTokenRequest().withDurationSeconds(43200);
// Get the session token for the service instance's bucket 
// Error initiated from here 
sessionCredentials = stsClient.getSessionToken(getSessionTokenRequest).getCredentials();
 

Ошибка:

 com.amazonaws.SdkClientException : Unable to execute HTTP request: sts.amazonaws.com
com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1207)
com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1153)
com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.doInvoke(AWSSecurityTokenServiceClient.java:1652)
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.invoke(AWSSecurityTokenServiceClient.java:1619)
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.invoke(AWSSecurityTokenServiceClient.java:1608)
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.executeGetSessionToken(AWSSecurityTokenServiceClient.java:1546)
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.getSessionToken(AWSSecurityTokenServiceClient.java:1516)
 

Ответ №1:

вы можете попробовать установить

 AWS_STS_REGIONAL_ENDPOINTS=regional
 

или другая конечная точка sts, зависящая от конкретного региона, задана явно.

пожалуйста, смотрите: https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html