Skip to content

Commit 884d5a5

Browse files
committed
Include step function
1 parent 4534a6d commit 884d5a5

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

cdk/quiz_app/quiz_app_stack.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
aws_iam as iam,
1212
aws_lambda as _lambda,
1313
aws_sns as sns,
14+
aws_stepfunctions as sfn,
1415
aws_pipes as pipes,
1516
aws_sqs as sqs,
1617
custom_resources as cr,
1718
CfnOutput as Output,
1819
)
19-
from constructs import Construct, ConstructOrder
20+
from constructs import Construct
2021

2122

2223
class QuizAppStack(Stack):
@@ -256,6 +257,43 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
256257
role_arn=pipes_role.role_arn,
257258
)
258259

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+
259297
@staticmethod
260298
def read_policy_file(file_path: str) -> dict:
261299
"""Reads a JSON policy file and returns it as a dictionary."""

0 commit comments

Comments
 (0)