-
Notifications
You must be signed in to change notification settings - Fork 38
/
aws_serverless_image_processing.py
executable file
·97 lines (76 loc) · 2.35 KB
/
aws_serverless_image_processing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python3
# coding=utf-8
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2023-04-18 17:42:57 +0100 (Tue, 18 Apr 2023)
#
# https://github.com/HariSekhon/Diagrams-as-Code
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn
# and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
# ported from here:
#
# https://cloudgram.dedalusone.com/examples.html
"""
AWS Serverless Image Processing
"""
__author__ = 'Hari Sekhon'
__version__ = '0.1'
import os
from diagrams import Diagram, Cluster
# ============================================================================ #
# AWS resources:
#
# https://diagrams.mingrammer.com/docs/nodes/aws
#
from diagrams.aws.compute import Lambda
from diagrams.aws.database import Dynamodb
from diagrams.aws.integration import Appsync, StepFunctions
from diagrams.aws.ml import Rekognition
from diagrams.aws.security import Cognito
from diagrams.aws.storage import S3
from diagrams.aws.general import User
# https://www.graphviz.org/doc/info/attrs.html
graph_attr = {
"splines": "spline", # rounded arrows, much nicer
}
# diagram name results in 'web_service.png' as the output name
# pylint: disable=W0104,W0106
with Diagram('AWS Serverless Image Processing',
show=not bool(os.environ.get('CI', 0)),
filename='images/aws_serverless_image_processing',
graph_attr=graph_attr,
):
appsync = Appsync("AWS AppSync")
user = User("User")
user >> Cognito("AWS Cognito")
user \
>> S3("AWS S3 Bucket") \
>> Lambda("Start workflow") \
>> appsync
user >> appsync
resolver = Lambda("AWS Resolver")
with Cluster("Backend"):
dynamodb = Dynamodb("AWS DynamoDB")
appsync \
>> resolver \
>> dynamodb
step_function = StepFunctions("AWS Step Function")
resolver \
>> step_function
step_function \
>> Lambda("Create thumbnail")
step_function \
>> Lambda("Persist Metadata") \
>> dynamodb
step_function \
>> Lambda("Extract metadata")
step_function \
>> Lambda("Object / Scene detection") \
>> Rekognition("AWS Rekognition")