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?