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?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
rajub
  • 320
  • 1
  • 5
  • 17
  • 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. – rajub Apr 16 '16 at 12:11
  • See my answer to this question: http://stackoverflow.com/questions/36508974/python-request-in-aws-lambda-timing-out/36509205#36509205 – Mark B Apr 16 '16 at 15:33
  • Did you associate it to a Public Subnet, or a Private Subnet? – John Rotenstein Apr 16 '16 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("http://stackoverflow.com/questions/36508974/python-request-in-aws-lambda-timing-out/36509205#36509205", 'GET', headers=headers) print "response ",response, respData – rajub Apr 20 '16 at 11:58

0 Answers0