Skip to content

Commit 5e9049d

Browse files
feat(event_sources): add queue_url field in SQS EventSource DataClass (#2146)
1 parent 180e528 commit 5e9049d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

aws_lambda_powertools/utilities/data_classes/sqs_event.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ def aws_region(self) -> str:
133133
"""aws region eg: us-east-1"""
134134
return self["awsRegion"]
135135

136+
@property
137+
def queue_url(self) -> str:
138+
"""The URL of the queue."""
139+
arn_parts = self["eventSourceARN"].split(":")
140+
region = arn_parts[3]
141+
account_id = arn_parts[4]
142+
queue_name = arn_parts[5]
143+
144+
queue_url = f"https://sqs.{region}.amazonaws.com/{account_id}/{queue_name}"
145+
146+
return queue_url
147+
136148

137149
class SQSEvent(DictWrapper):
138150
"""SQS Event

tests/functional/test_data_classes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ def test_seq_trigger_event():
779779
assert record.md5_of_body == "e4e68fb7bd0e697a0ae8f1bb342846b3"
780780
assert record.event_source == "aws:sqs"
781781
assert record.event_source_arn == "arn:aws:sqs:us-east-2:123456789012:my-queue"
782+
assert record.queue_url == "https://sqs.us-east-2.amazonaws.com/123456789012/my-queue"
782783
assert record.aws_region == "us-east-2"
783784

784785

0 commit comments

Comments
 (0)