У меня есть супер простой проект MVN, который выполняет некоторый код, чтобы получить теги лямбда-функции с учетом арн.
public static void listTag(String lambdaArn) {
final AWSLambdaAsync lambdaClient = AWSLambdaAsyncClientBuilder.standard()
.withRegion(Regions.EU_WEST_1)
.build();
final ListTagsRequest listTagsRequest = new ListTagsRequest();
listTagsRequest.setResource(lambdaArn);
final ListTagsResult listTagsResult = lambdaClient.listTags(listTagsRequest);
final Map<String, String> tags = listTagsResult.getTags();
...
}
Код работает отлично, и я могу получить теги.
Если я вызываю точно такой же код из метода внутри @RestController
класса в приложении Spring Boot, он больше не работает, и я получаю следующее:
2019-05-23 10:16:51.075 ERROR 26045 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.amazonaws.services.lambda.model.AWSLambdaException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: AWSLambda; Status Code: 403; Error Code: InvalidSignatureException; Request ID: 7fb1ecf0-7d3b-11e9-89c2-8775f15f937d)] with root cause
com.amazonaws.services.lambda.model.AWSLambdaException: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details. (Service: AWSLambda; Status Code: 403; Error Code: InvalidSignatureException; Request ID: 7fb1ecf0-7d3b-11e9-89c2-8775f15f937d)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1712) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1113) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:770) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:744) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532) ~[aws-java-sdk-core-1.11.534.jar:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512) ~[aws-java-sdk-core-1.11.534.jar:na]
Конечно, я пытался добавить свои учетные данные при сборке клиента, добавив
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("accessKey", "secretKey")))
Обе версии библиотеки и Java одинаковы. Spring boot - версия 2.1.3. ПОЖАЛУЙСТА, если это может помочь.