2

I am having trouble getting the queue using boto3 in an AWS Lambda function.

If I type the code below and run directly then it is working. However, if I create the package and upload the zip file, it not working.

My sample code is as:

import boto3
import json

print('Loading function')

def lambda_handler(event, context):
sqs = boto3.resource('sqs', region_name='us-west-2', aws_access_key_id='XXXXXXXXXXXXXXX', aws_secret_access_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

for queue in sqs.queues.all():
    print("===="+str(queue))

queue = sqs.get_queue_by_name(QueueName='testqueue')
print(" queue :: "+str(queue))

Why is it not working with package zip file?

4
  • I got the problem root cause of problem. I selected the VPC in lambda function configuration, if i remove VPC than it's working. How to solve this problem. Commented Apr 16, 2016 at 12:11
  • See my answer to this question: stackoverflow.com/questions/36508974/… Commented Apr 16, 2016 at 15:33
  • Did you associate it to a Public Subnet, or a Private Subnet? Commented Apr 16, 2016 at 23:42
  • Hi John, Thanks for response. I associated it to a Public Subnet. If i make a simple http request getting the timeout. headers = {'content-type': 'application/json'} http = httplib2.Http(disable_ssl_certificate_validation=True) print "before http request" response, respData = http.request("stackoverflow.com/questions/36508974/…", 'GET', headers=headers) print "response ",response, respData Commented Apr 20, 2016 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.