-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.yml
89 lines (79 loc) · 2.41 KB
/
template.yml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An Amazon SQS trigger that uses Rekognition API and writes image content to a DynamoDB table
Parameters:
BUCKETNAME:
Type: String
Description: S3 Bucket name containing celebrity images
MinLength: 4
MaxLength: 50
TABLENAME:
Type: String
Description: The DynamoDB table for storing Rekognition output values. Minimum 4 characters
Default: 'SQSESDDBTable'
MinLength: 4
MaxLength: 50
AllowedPattern: ^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$
ConstraintDescription: 'Required parameter.'
QUEUENAME:
Type: String
Description: Queue name containing image information
Default: 'ESLambdaQ'
AllowedPattern: ^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$
Outputs:
ImageBucket:
Description: S3 Bucket where the images needs to be uploaded.
Value: !Ref BUCKETNAME
OutputDDBTable:
Description: DynamoDB table where the Rekognition output will be stored.
Value: !Ref TABLENAME
SQSQueueName:
Description: SQS Queue to which the image name will be published.
Value: !Ref QUEUENAME
Resources:
SQSLambda:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.6
CodeUri: ./src
Description: 'An Amazon SQS trigger that uses Rekognition API and writes image content to a DynamoDB table'
MemorySize: 128
Timeout: 300
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref TABLENAME
- S3ReadPolicy:
BucketName: !Ref BUCKETNAME
- SQSPollerPolicy:
QueueName: !Ref QUEUENAME
Environment:
Variables:
BucketName: !Ref BUCKETNAME
DynamoDBTableName: !Ref TABLENAME
ImageBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BUCKETNAME
SQSQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: !Ref QUEUENAME
VisibilityTimeout: 3000
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref TABLENAME
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5