forked from rgfindl/serverless-contact-us-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.yml
82 lines (78 loc) · 1.9 KB
/
stack.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
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Serverless Contact Us form for static website
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Configuration"
Parameters:
- Subject
- ToEmailAddress
- ReCaptchaSecret
Parameters:
Subject:
Type: String
Description: Contact us email subject
ToEmailAddress:
Type: String
Description: Email address you want contact form submittions to go to
ReCaptchaSecret:
Type: String
Description: Your Google reCAPTCHA secret
Resources:
#
# SNS Topic
#
ContactUsSNSTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName:
Fn::Join:
- ''
- - Ref: AWS::StackName
- ' Topic'
Subscription:
- Endpoint: !Ref ToEmailAddress
Protocol: email
TopicName:
Fn::Join:
- ''
- - Ref: AWS::StackName
- '-topic'
#
# Our Lambda function. Basic code has been added. You will replace the code later via your Github repo.
#
ContactUsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Timeout: 5
CodeUri: ./index.js
Runtime: nodejs12.x
Policies:
- SNSPublishMessagePolicy:
TopicName: !GetAtt ContactUsSNSTopic.TopicName
Events:
PostEvent:
Type: Api
Properties:
Path: /
Method: post
Environment:
Variables:
ReCaptchaSecret: !Ref ReCaptchaSecret
ContactUsSNSTopic: !Ref ContactUsSNSTopic
Subject: !Ref Subject
Outputs:
ApiUrl:
Description: URL of your API endpoint
Value: !Join
- ''
- - https://
- !Ref ServerlessRestApi
- '.execute-api.'
- !Ref 'AWS::Region'
- '.amazonaws.com/Prod'