forked from simalexan/api-lambda-send-email-ses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
45 lines (45 loc) · 1.52 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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Parameters:
FromEmail:
Type: String
Default: '[email protected]'
Description: (Required) Represents the email sender. Must be a SES verified email. If you attempt to send email using a non-verified address or domain, the operation results in an "Email address not verified" error. Minimum 4 characters.
MinLength: 4
MaxLength: 70
ConstraintDescription: 'Required. Must be a SES verified email address.'
CorsOrigin:
Type: String
Default: ''
Description: (Optional) Cross-origin resource sharing (CORS) Origin. You can specify a single origin, all "*" or leave empty and no CORS will be applied.
MaxLength: 250
Conditions:
IsCorsDefined: !Not [!Equals [!Ref CorsOrigin, '']]
Resources:
LambdaEmailer:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs8.10
Environment:
Variables:
FROM_EMAIL: !Ref FromEmail
CORS_ORIGIN: !Ref CorsOrigin
Policies:
- SESCrudPolicy:
IdentityName: !Ref FromEmail
Events:
EmailApi:
Type: Api
Properties:
Path: /send
Method: POST
EmailOptionsApi:
Type: Api
Properties:
Path: /send
Method: OPTIONS
Outputs:
ApiUrl:
Value: !Sub https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/send
Description: The URL of the API Gateway you should invoke to send an email