0

I am getting following error when i try to create/delete queue using aws-sdk-cpp and aws-sdk-sqs:- error = {m_errorType=ACCESS_DENIED (15) m_exceptionName="AccessDenied" m_message="Access to the resource https://sqs.ap-south-1.amazonaws.com/ is denied." ...}

I can create queue by logging to amazon console, but cannot do so using api(aws-sdk-cpp and aws-sdk-sqs). I am even able to send and receive msgs from queue using api. But I am not able to create/delete queue using api.

I have used following link as reference:- https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/cpp/example_code/sqs/create_queue.cpp

Following is my code:-

void createqueue()
{   
    Aws::Client::ClientConfiguration  CliConfig;

    CliConfig.region = "ap-south-1";

    Aws::SQS::SQSClient sqs(CliConfig);

    Aws::SQS::Model::CreateQueueRequest cq_req;

    Aws::String queue_name = "asdf";
    cq_req.SetQueueName(queue_name);

    Aws::Auth::AWSCredentials("************", "*****************");

    auto cq_out = sqs.CreateQueue(cq_req);
    if (cq_out.IsSuccess())
    {
        std::cout << "Successfully created queue " << queue_name << std::endl;
    }
    else
    {
        std::cout << "Error creating queue " << queue_name << ": " <<
            cq_out.GetError().GetMessage() << std::endl;
    }
}
AbhiK
  • 247
  • 3
  • 19
  • Please read [the help pages](http://stackoverflow.com/help), especially ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask) and [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). Lastly learn how to create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve). – Some programmer dude Oct 18 '18 at 06:10
  • And please learn how to *edit* your questions. – Some programmer dude Oct 18 '18 at 06:10

1 Answers1

0

The AWS credentials used to create or delete the SQS queue must allow those operations.

The credentials defined in your sample code are having no effect. Credentials can be passed to the SQSClient constructor or they can be defined as described at https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/credentials.html