@@ -19,4 +19,58 @@ queue_url=$(awslocal sqs create-queue \
1919
2020echo " SQS Queue created: $queue_url "
2121
22+ # Get the SQS Queue ARN
23+ queue_arn=$( awslocal sqs get-queue-attributes \
24+ --queue-url " $queue_url " \
25+ --attribute-name QueueArn \
26+ --output text \
27+ --query ' Attributes.QueueArn' )
28+
29+ echo " SQS Queue ARN: $queue_arn "
30+
31+ # Create SNS Topics
32+ topic_arn=$( awslocal sns create-topic \
33+ --name ls-keeper-data-bridge-events \
34+ --endpoint-url=http://localhost:4566 \
35+ --output text \
36+ --query ' TopicArn' )
37+
38+ echo " SNS Topic created: $topic_arn "
39+
40+ # Construct the policy JSON inline with escaped quotes
41+ policy_json=$( cat << EOF
42+ {
43+ "Version": "2012-10-17",
44+ "Statement": [
45+ {
46+ "Effect": "Allow",
47+ "Principal": "*",
48+ "Action": "sqs:SendMessage",
49+ "Resource": "$queue_arn ",
50+ "Condition": {
51+ "ArnEquals": {
52+ "aws:SourceArn": "$topic_arn "
53+ }
54+ }
55+ }
56+ ]
57+ }
58+ EOF
59+ )
60+
61+ # Set SQS policy
62+ awslocal sqs set-queue-attributes \
63+ --queue-url " $queue_url " \
64+ --attributes " {\" Policy\" : \" $(
65+ echo " $policy_json " | jq -c
66+ ) \" }"
67+
68+ # Subscribe the Queue to the Topic
69+ awslocal sns subscribe \
70+ --topic-arn " $topic_arn " \
71+ --protocol sqs \
72+ --notification-endpoint " $queue_arn "
73+
74+ echo " SNS Topic subscription complete"
75+
2276echo " Bootstrapping Complete"
0 commit comments