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;
}
}