|
11 | 11 | aws_iam as iam, |
12 | 12 | aws_lambda as _lambda, |
13 | 13 | aws_sns as sns, |
| 14 | + aws_stepfunctions as sfn, |
14 | 15 | aws_pipes as pipes, |
15 | 16 | aws_sqs as sqs, |
16 | 17 | custom_resources as cr, |
17 | 18 | CfnOutput as Output, |
18 | 19 | ) |
19 | | -from constructs import Construct, ConstructOrder |
| 20 | +from constructs import Construct |
20 | 21 |
|
21 | 22 |
|
22 | 23 | class QuizAppStack(Stack): |
@@ -256,6 +257,43 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
256 | 257 | role_arn=pipes_role.role_arn, |
257 | 258 | ) |
258 | 259 |
|
| 260 | + # state machine |
| 261 | + |
| 262 | + policy_document = iam.PolicyDocument.from_json( |
| 263 | + { |
| 264 | + "Version": "2012-10-17", |
| 265 | + "Statement": [ |
| 266 | + { |
| 267 | + "Effect": "Allow", |
| 268 | + "Action": [ |
| 269 | + "ses:SendEmail", |
| 270 | + "ses:SendRawEmail", |
| 271 | + "sesv2:SendEmail", |
| 272 | + ], |
| 273 | + "Resource": "*", |
| 274 | + } |
| 275 | + ], |
| 276 | + } |
| 277 | + ) |
| 278 | + policy = iam.ManagedPolicy( |
| 279 | + self, "SendEmailStateMachinePolicy", document=policy_document |
| 280 | + ) |
| 281 | + state_machine_role = iam.Role( |
| 282 | + self, |
| 283 | + "SendEmailStateMachineRole", |
| 284 | + assumed_by=iam.ServicePrincipal("states.amazonaws.com"), |
| 285 | + managed_policies=[policy], |
| 286 | + ) |
| 287 | + |
| 288 | + self.state_machine = sfn.StateMachine( |
| 289 | + self, |
| 290 | + "SendEmailStateMachine", |
| 291 | + definition_body=sfn.DefinitionBody.from_file( |
| 292 | + "../configurations/statemachine.json" |
| 293 | + ), |
| 294 | + role=state_machine_role, |
| 295 | + ) |
| 296 | + |
259 | 297 | @staticmethod |
260 | 298 | def read_policy_file(file_path: str) -> dict: |
261 | 299 | """Reads a JSON policy file and returns it as a dictionary.""" |
|
0 commit comments