aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.67k stars 1.01k forks source link

Insufficient role permissions to call `sqs.get_queue_by_name(...)` #2028

Open nRewik opened 1 year ago

nRewik commented 1 year ago

Use case: get (and work with) queue by name.

sqs = boto3.resource('sqs')
queue = sqs.get_queue_by_name(...)

Problem: Error when executing code on Lambda due to missing "GetQueueUrl" permission in autogen policy.

Workaround: Forcing autogen policy to attach GetQueueUrl via sqs_client.get_queue_url(...) API.

sqs = boto3.resource('sqs')
sqs_client = boto3.client('sqs')
queue_url = sqs_client.get_queue_url(QueueName='<queue_name>')['QueueUrl']
queue = sqs.Queue(url=queue_url)