|
16 | 16 | custom_resources as cr, |
17 | 17 | CfnOutput as Output, |
18 | 18 | ) |
19 | | -from constructs import Construct |
| 19 | +from constructs import Construct, ConstructOrder |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class QuizAppStack(Stack): |
@@ -64,7 +64,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
64 | 64 | write_capacity=5, |
65 | 65 | ) |
66 | 66 |
|
67 | | - dlq_submission_queue = sqs.Queue(self, "QuizSubmissionQueueDLQ") |
| 67 | + dlq_submission_queue = sqs.Queue(self, "QuizSubmissionDLQ") |
68 | 68 | submission_queue = sqs.Queue( |
69 | 69 | self, |
70 | 70 | "QuizSubmissionQueue", |
@@ -214,6 +214,48 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
214 | 214 | ) |
215 | 215 | ) |
216 | 216 |
|
| 217 | + # eventbridge pipe |
| 218 | + policy_document = iam.PolicyDocument.from_json( |
| 219 | + { |
| 220 | + "Version": "2012-10-17", |
| 221 | + "Statement": [ |
| 222 | + { |
| 223 | + "Effect": "Allow", |
| 224 | + "Action": [ |
| 225 | + "sqs:ReceiveMessage", |
| 226 | + "sqs:DeleteMessage", |
| 227 | + "sqs:GetQueueAttributes", |
| 228 | + "sqs:GetQueueUrl", |
| 229 | + ], |
| 230 | + "Resource": dlq_submission_queue.queue_arn, |
| 231 | + }, |
| 232 | + { |
| 233 | + "Effect": "Allow", |
| 234 | + "Action": "sns:Publish", |
| 235 | + "Resource": dlq_alarm_topic.topic_arn, |
| 236 | + }, |
| 237 | + ], |
| 238 | + } |
| 239 | + ) |
| 240 | + policy = iam.ManagedPolicy( |
| 241 | + self, |
| 242 | + "PipesPolicy", |
| 243 | + document=policy_document, |
| 244 | + ) |
| 245 | + pipes_role = iam.Role( |
| 246 | + self, |
| 247 | + f"PipeRole", |
| 248 | + assumed_by=iam.ServicePrincipal("pipes.amazonaws.com"), |
| 249 | + managed_policies=[policy], |
| 250 | + ) |
| 251 | + pipe = pipes.CfnPipe( |
| 252 | + self, |
| 253 | + "DLQToSNSPipe", |
| 254 | + source=dlq_submission_queue.queue_arn, |
| 255 | + target=dlq_alarm_topic.topic_arn, |
| 256 | + role_arn=pipes_role.role_arn, |
| 257 | + ) |
| 258 | + |
217 | 259 | @staticmethod |
218 | 260 | def read_policy_file(file_path: str) -> dict: |
219 | 261 | """Reads a JSON policy file and returns it as a dictionary.""" |
|
0 commit comments