Amazon SQS Access Denied Exception

0

I am trying to send messages to an SQS queue. For local environment I am setting up the AmazonSQS object like below

amazonSQS =
AmazonSQSClientBuilder.standard()
    .withCredentials(
        new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)))
    .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
    .build();

For my development environment I am setting up like below:

amazonSQS = AmazonSQSClientBuilder.defaultClient();

The tests run fine locally but in my dev environment, I am getting the below error:

com.amazonaws.services.sqs.model.AmazonSQSException: Access to the resource https://sqs.us-east-1.amazonaws.com/2092384092384/error-handler-queue is denied. (Service: AmazonSQS; Status Code: 403; Error Code: AccessDenied; Request ID: 7bc7e074-a36a-544d-9489-bbe66133f0a8; Proxy: null)

What could be the issue ? Any help is appreciated

已提問 2 年前檢視次數 1465 次
1 個回答
0

Hi, @sniranjan.

It looks like you're not using credentials with the proper permissions.

Where is your development environment hosted? EC2? Lambda?
I assume you're using the AWS SDK for Java, but check the credentials below. Check your environment variables and instance profile.

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html

Next, if you can get IAM information, first check if the IAM policy settings are the same as your local environment. (In the end it's correct to set least privilege)

profile picture
專家
iwasa
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南