My code:
require 'aws-sdk'
module SqsTest
access_key_id = $access_key_id
secret_access_key=$secret_access_key
session_token = $session_token
sqs_client = Aws::SQS::Client.new(
region: 'us-east-1',
credentials:Aws::Credentials.new(access_key_id, secret_access_key,session_token )
)
queue_url = sqs_client.get_queue_url(queue_name: 'test-queue').queue_url
# puts queue_url
def purge(options = {})
options = options.merge(queue_url: '{here is the queue link}')
resp = Aws::Plugins::UserAgent.feature('resource') do
sqs_client.purge_queue(options)
end
resp.data
end
purge
end
I had learned that to call a method with ruby you just need to invoke the method name, and normally that works for me, but apparently inside a module it doesn't. I wanted to understand why and if anyone knows how to invoke the method in this case.
I called the module name before the method name, like this:
and then it worked.