尝试使用AWSSDK从java应用程序连接sqs时发生403禁止错误

oknrviil  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(331)

我尝试在prod环境中使用aws sdk从java应用程序访问sqs队列,如下所示:

@Profile("prod")
  @Bean
  public AmazonSQSAsyncClient getAmazonSQSClientProd() {
    return (AmazonSQSAsyncClient) AmazonSQSAsyncClientBuilder.standard()
        .withRegion(Regions.fromName(awsRegion))
        .withCredentials(InstanceProfileCredentialsProvider.getInstance())
        .build();

运行应用程序时,出现以下异常:

15:06:12.415 [task-57] ERROR c.s.t.m.s.producer.SqsDataPublisher - Received exception from sqs
com.amazonaws.services.sqs.model.AmazonSQSException: Access to the resource https://sqs.us-west-2.amazonaws.com/123456/queue_1.fifo is denied. (Service: AmazonSQS; Status Code: 403; Error Code: AccessDenied; Request ID: 8901234)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1712)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1113)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:744)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686)
    at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512)
    at com.amazonaws.services.sqs.AmazonSQSClient.doInvoke(AmazonSQSClient.java:2202)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2169)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2158)
    at com.amazonaws.services.sqs.AmazonSQSClient.executeSendMessage(AmazonSQSClient.java:1757)
    at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1729)
    at com.salesforce.tm.messaging.sqs.producer.SqsDataPublisher.sendMessageAndWaitForResult(SqsDataPublisher.java:54)
    at com.salesforce.tm.messaging.sqs.producer.SqsDataPublisher.sendInternal(SqsDataPublisher.java:60)
    at com.salesforce.tm.messaging.sqs.producer.SqsDataPublisher.sendMessage(SqsDataPublisher.java:104)
    at com.salesforce.tm.messaging.sqs.producer.SqsDataPublisher.sendMessage(SqsDataPublisher.java:81)
    at com.salesforce.tm.messaging.sqs.producer.SqsDataPublisher.sendMessage(SqsDataPublisher.java:72)
    at com.salesforce.tm.auditlog.AuditLogInterceptorHelper.saveAndPublish(AuditLogInterceptorHelper.java:36)
    at com.salesforce.tm.auditlog.AuditLogInterceptorHelper$$FastClassBySpringCGLIB$$1ef9aa98.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

我不知道如何解决这个问题。
有人能帮忙吗?谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题