|
11 | 11 | aws_iam as iam, |
12 | 12 | aws_lambda as _lambda, |
13 | 13 | aws_sns as sns, |
| 14 | + aws_pipes as pipes, |
14 | 15 | aws_sqs as sqs, |
| 16 | + custom_resources as cr, |
15 | 17 | CfnOutput as Output, |
16 | 18 | ) |
17 | 19 | from constructs import Construct |
@@ -62,7 +64,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
62 | 64 | write_capacity=5, |
63 | 65 | ) |
64 | 66 |
|
65 | | - dlq_submission_queue = sqs.Queue(self, "QuizSubmissionQueue") |
| 67 | + dlq_submission_queue = sqs.Queue(self, "QuizSubmissionQueueDLQ") |
66 | 68 | submission_queue = sqs.Queue( |
67 | 69 | self, |
68 | 70 | "QuizSubmissionQueue", |
@@ -184,9 +186,33 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
184 | 186 | ) |
185 | 187 | resource.add_method(http_method, integration=integration) |
186 | 188 |
|
187 | | - # SQS DLQ -> EventBridge Pipes -> SNS |
188 | | - dlq_alarm_topic = sns.Topic(self, "DLQAlarmTopic") |
| 189 | + # verify email identity for SES |
| 190 | + |
| 191 | + sanitised_email = email.replace(".", "-").replace("@", "-") |
| 192 | + cr.AwsCustomResource( |
| 193 | + self, |
| 194 | + f"EmailVerifier{sanitised_email}", |
| 195 | + on_update=cr.AwsSdkCall( |
| 196 | + service="SES", |
| 197 | + action="VerifyEmailIdentity", |
| 198 | + parameters={ |
| 199 | + "EmailAddress": email, |
| 200 | + }, |
| 201 | + physical_resource_id=cr.PhysicalResourceId.of( |
| 202 | + f"verify-{sanitised_email}" |
| 203 | + ), |
| 204 | + ), |
| 205 | + policy=cr.AwsCustomResourcePolicy.from_sdk_calls( |
| 206 | + resources=cr.AwsCustomResourcePolicy.ANY_RESOURCE, |
| 207 | + ), |
| 208 | + ) |
189 | 209 |
|
| 210 | + dlq_alarm_topic = sns.Topic(self, "DLQAlarmTopic") |
| 211 | + dlq_alarm_topic.add_subscription( |
| 212 | + aws_cdk.aws_sns_subscriptions.EmailSubscription( |
| 213 | + email_address="[email protected]", |
| 214 | + ) |
| 215 | + ) |
190 | 216 |
|
191 | 217 | @staticmethod |
192 | 218 | def read_policy_file(file_path: str) -> dict: |
|
0 commit comments