forked from jbesw/aws-serverless-form-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
69 lines (65 loc) · 2.1 KB
/
template.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Serverless Form Handler - accepts a form submission from a webpage, saving the data to a DynamoDB table and sending an email via SES.
Parameters:
ValidatedEmail:
Type: String
Description: (Required) A validated SES email address for receiving new submissions.
MaxLength: 70
Default: validated@email.com
MinLength: 4
ConstraintDescription: Required. Must be a SES verified email address.
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Api:
EndpointConfiguration: EDGE
Cors:
AllowMethods: "'OPTIONS,POST'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"
Resources:
FormDataTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: formId
AttributeType: S
KeySchema:
- AttributeName: formId
KeyType: HASH
BillingMode: PAY_PER_REQUEST
SubmitFormFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: submitFormFunction/
Handler: app.handler
Runtime: nodejs8.10
MemorySize: 128
Environment:
Variables:
ValidatedEmail: !Ref ValidatedEmail
FormDataTable: !Ref FormDataTable
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref FormDataTable
- SESCrudPolicy:
IdentityName: !Ref ValidatedEmail
Events:
HttpPost:
Type: Api
Properties:
Path: '/submitForm'
Method: post
Outputs:
SubmitFormFunction:
Description: "Lambda Function ARN"
Value: !GetAtt SubmitFormFunction.Arn
SubmitFormFunctionIamRole:
Description: "Implicit IAM Role created for function"
Value: !GetAtt SubmitFormFunctionRole.Arn
FormDataTable:
Description: DynamoDB Table
Value: !Ref FormDataTable