├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── license.txt ├── submitFormFunction ├── app.js ├── dynamodb.js ├── package.json ├── ses.js └── testHarness.js └── template.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/osx,node,linux,windows 3 | 4 | ### Linux ### 5 | *~ 6 | 7 | # temporary files which can be created if a process still has a handle open of a deleted file 8 | .fuse_hidden* 9 | 10 | # KDE directory preferences 11 | .directory 12 | 13 | # Linux trash folder which might appear on any partition or disk 14 | .Trash-* 15 | 16 | # .nfs files are created when an open file is removed but is still being accessed 17 | .nfs* 18 | 19 | ### Node ### 20 | # Logs 21 | logs 22 | *.log 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # Runtime data 28 | pids 29 | *.pid 30 | *.seed 31 | *.pid.lock 32 | 33 | # Directory for instrumented libs generated by jscoverage/JSCover 34 | lib-cov 35 | 36 | # Coverage directory used by tools like istanbul 37 | coverage 38 | 39 | # nyc test coverage 40 | .nyc_output 41 | 42 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 43 | .grunt 44 | 45 | # Bower dependency directory (https://bower.io/) 46 | bower_components 47 | 48 | # node-waf configuration 49 | .lock-wscript 50 | 51 | # Compiled binary addons (http://nodejs.org/api/addons.html) 52 | build/Release 53 | 54 | # Dependency directories 55 | node_modules/ 56 | jspm_packages/ 57 | 58 | # Typescript v1 declaration files 59 | typings/ 60 | 61 | # Optional npm cache directory 62 | .npm 63 | 64 | # Optional eslint cache 65 | .eslintcache 66 | 67 | # Optional REPL history 68 | .node_repl_history 69 | 70 | # Output of 'npm pack' 71 | *.tgz 72 | 73 | # Yarn Integrity file 74 | .yarn-integrity 75 | 76 | # dotenv environment variables file 77 | .env 78 | 79 | 80 | ### OSX ### 81 | *.DS_Store 82 | .AppleDouble 83 | .LSOverride 84 | 85 | # Icon must end with two \r 86 | Icon 87 | 88 | # Thumbnails 89 | ._* 90 | 91 | # Files that might appear in the root of a volume 92 | .DocumentRevisions-V100 93 | .fseventsd 94 | .Spotlight-V100 95 | .TemporaryItems 96 | .Trashes 97 | .VolumeIcon.icns 98 | .com.apple.timemachine.donotpresent 99 | 100 | # Directories potentially created on remote AFP share 101 | .AppleDB 102 | .AppleDesktop 103 | Network Trash Folder 104 | Temporary Items 105 | .apdisk 106 | 107 | ### Windows ### 108 | # Windows thumbnail cache files 109 | Thumbs.db 110 | ehthumbs.db 111 | ehthumbs_vista.db 112 | 113 | # Folder config file 114 | Desktop.ini 115 | 116 | # Recycle Bin used on file shares 117 | $RECYCLE.BIN/ 118 | 119 | # Windows Installer files 120 | *.cab 121 | *.msi 122 | *.msm 123 | *.msp 124 | 125 | # Windows shortcuts 126 | *.lnk 127 | 128 | 129 | # End of https://www.gitignore.io/api/osx,node,linux,windows -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Serverless Form Handler 2 | 3 | The Serverless Form Handler accepts a form submission from a webpage, saving the data to a DynamoDB table and sending an email via SES. 4 | 5 | Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS pricing page](https://aws.amazon.com/pricing/) for details. 6 | 7 | ```bash 8 | . 9 | ├── README.MD <-- This instructions file 10 | ├── submitFormFunction <-- Source code for the main lambda function 11 | │ └── app.js <-- Main Lambda handler 12 | │ └── dynamodb.js <-- DynamoDB helper function 13 | │ └── ses.js <-- Wrapper for Amazon SES 14 | │ └── testHarness.js <-- For testing code locally 15 | │ └── package.json <-- NodeJS dependencies and scripts 16 | ├── template.yaml <-- SAM template 17 | ``` 18 | 19 | ## Requirements 20 | 21 | * AWS CLI already configured with Administrator permission 22 | * [NodeJS 12.x installed](https://nodejs.org/en/download/) 23 | 24 | ## Installation Instructions 25 | 26 | 1. [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and login. 27 | 1. Go to the app's page on the [Serverless Application Repository](https://serverlessrepo.aws.amazon.com/applications/) and click "Deploy" 28 | 1. Provide the required app parameters (see parameter details below) and click "Deploy" 29 | 30 | ## Parameter Details 31 | 32 | * Validated email: provided an email address that has been validated in the Amazon SES service in the same region when you are deploying this application. For instructions on how to validate an email in SES, see [this page](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses-procedure.html). 33 | 34 | ## Using this Application 35 | 36 | * This application creates an API Gateway endpoint where browser-based forms can send text-based form data. The application will store the response in a DynamoDB table and email the form data to the Validated Email. 37 | * This application is for educational purposes and does not provide any throttling on the API Gateway endpoint. For production usage, you should [apply throttling to your API resources](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-request-throttling.html). 38 | 39 | ## How it works 40 | 41 | * Deploy this serverless application and take a note of the API endpoint. 42 | * Create a form in a webpage and use the Javascript handling functon as shown in [this Gist](https://gist.github.com/jbesw/b75a2409521e2ff632dce7c8e07d6d2a) for an example. Use the API endpoint in the AJAX request to process the form data. 43 | 44 | ============================================== 45 | 46 | Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 47 | 48 | SPDX-License-Identifier: MIT-0 -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 10 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 11 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 12 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 13 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 14 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /submitFormFunction/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 9 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 10 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 11 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 12 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 13 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | 'use strict' 17 | 18 | /** 19 | * 20 | * Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format 21 | * @param {Object} event - API Gateway Lambda Proxy Input Format 22 | * 23 | */ 24 | 25 | const { saveFormData } = require('./dynamodb') 26 | const { sendEmail } = require('./ses') 27 | 28 | const headers = { 29 | 'Content-Type': 'application/json', 30 | 'Access-Control-Allow-Origin': '*', 31 | 'Access-Control-Allow-Headers': "Content-Type", 32 | "Access-Control-Allow-Methods": "OPTIONS,POST" 33 | } 34 | 35 | // Main Lambda entry point 36 | exports.handler = async (event) => { 37 | 38 | console.log(`Started with: ${event.body}`) 39 | const formData = JSON.parse(event.body) 40 | 41 | try { 42 | // Send email and save to DynamoDB in parallel using Promise.all 43 | await Promise.all([sendEmail(formData), saveFormData(formData)]) 44 | 45 | return { 46 | statusCode: 200, 47 | body: 'OK!', 48 | headers 49 | } 50 | } catch(err) { 51 | console.error('handler error: ', err) 52 | 53 | return { 54 | statusCode: 500, 55 | body: 'Error', 56 | headers 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /submitFormFunction/dynamodb.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 9 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 10 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 11 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 12 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 13 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | 'use strict' 17 | 18 | const AWS = require('aws-sdk') 19 | AWS.config.update({ region: process.env.AWS_REGION || 'us-east-1' }) 20 | const documentClient = new AWS.DynamoDB.DocumentClient() 21 | 22 | // DynamoDB functions. 23 | 24 | const saveFormData = async (formData) => { 25 | return new Promise((resolve, reject) => { 26 | const params = { 27 | TableName: process.env.FormDataTable, 28 | Item: { 29 | formId: Math.floor(Math.random() * Math.floor(10000000)).toString(), 30 | formData: JSON.stringify(formData), //stringify to store against empty responses in form 31 | created: Math.floor(Date.now() / 1000) 32 | } 33 | } 34 | console.log(params) 35 | documentClient.put(params, function(err, data) { 36 | if (err) { 37 | console.error(err) 38 | reject(err) 39 | } 40 | else resolve(data) 41 | }) 42 | }) 43 | } 44 | 45 | module.exports = { saveFormData } 46 | -------------------------------------------------------------------------------- /submitFormFunction/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "form-handler", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "James Beswick, Amazon Web Services", 11 | "license": "MIT", 12 | "dependencies": { 13 | "aws-sdk": "^2.714.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /submitFormFunction/ses.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 9 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 10 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 11 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 12 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 13 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | 'use strict' 17 | 18 | const AWS = require('aws-sdk') 19 | AWS.config.update({ region: process.env.AWS_REGION || 'us-east-1' }) 20 | const SES = new AWS.SES() 21 | 22 | const sendEmail = async function (formData) { 23 | 24 | const getContent = (formData) => { 25 | let retval = '' 26 | for (var attribName in formData){ 27 | retval += attribName + ': ' + formData[attribName] + '\n\n' 28 | } 29 | return retval 30 | } 31 | 32 | return new Promise(async (resolve, reject) => { 33 | 34 | // Build params for SES 35 | const emailParams = { 36 | Source: process.env.ValidatedEmail, // SES SENDING EMAIL 37 | ReplyToAddresses: [process.env.ValidatedEmail], 38 | Destination: { 39 | ToAddresses: [process.env.ValidatedEmail], // SES RECEIVING EMAIL 40 | }, 41 | Message: { 42 | Body: { 43 | Text: { 44 | Charset: 'UTF-8', 45 | Data: getContent(formData) 46 | }, 47 | }, 48 | Subject: { 49 | Charset: 'UTF-8', 50 | Data: 'New Form Submission' 51 | }, 52 | }, 53 | } 54 | // Send the email 55 | try { 56 | const result = await SES.sendEmail(emailParams).promise() 57 | console.log('sendEmail result: ', result) 58 | resolve() 59 | } catch (err) { 60 | console.error('sendEmail error: ', err) 61 | reject() 62 | } 63 | }) 64 | } 65 | 66 | module.exports = { sendEmail } -------------------------------------------------------------------------------- /submitFormFunction/testHarness.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 9 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 10 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 11 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 12 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 13 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | */ 15 | 16 | const { handler } = require('./app') 17 | 18 | // Mock event 19 | const event = { 20 | "body": "{\"name\": \"Sender Name\",\"reply_to\": \"sender@email.com\",\"message\": \"A test message\"}" 21 | } 22 | 23 | const main = async () => { 24 | await handler(event) 25 | } 26 | 27 | main() 28 | 29 | -------------------------------------------------------------------------------- /template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: '2010-09-09' 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: > 4 | Serverless Form Handler - accepts a form submission from a webpage, saving the data to a DynamoDB table and sending an email via SES. 5 | 6 | Parameters: 7 | ValidatedEmail: 8 | Type: String 9 | Description: (Required) A validated SES email address for receiving new submissions. 10 | MaxLength: 70 11 | Default: validated@email.com 12 | MinLength: 4 13 | ConstraintDescription: Required. Must be a SES verified email address. 14 | 15 | # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst 16 | Globals: 17 | Function: 18 | Timeout: 10 19 | Api: 20 | EndpointConfiguration: EDGE 21 | Cors: 22 | AllowMethods: "'OPTIONS,POST'" 23 | AllowHeaders: "'Content-Type'" 24 | AllowOrigin: "'*'" 25 | 26 | Resources: 27 | FormDataTable: 28 | Type: AWS::DynamoDB::Table 29 | Properties: 30 | AttributeDefinitions: 31 | - AttributeName: formId 32 | AttributeType: S 33 | KeySchema: 34 | - AttributeName: formId 35 | KeyType: HASH 36 | BillingMode: PAY_PER_REQUEST 37 | SubmitFormFunction: 38 | Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction 39 | Properties: 40 | CodeUri: submitFormFunction/ 41 | Handler: app.handler 42 | Runtime: nodejs16.x 43 | MemorySize: 128 44 | Environment: 45 | Variables: 46 | ValidatedEmail: !Ref ValidatedEmail 47 | FormDataTable: !Ref FormDataTable 48 | Policies: 49 | - DynamoDBCrudPolicy: 50 | TableName: !Ref FormDataTable 51 | - SESCrudPolicy: 52 | IdentityName: !Ref ValidatedEmail 53 | Events: 54 | HttpPost: 55 | Type: Api 56 | Properties: 57 | Path: '/submitForm' 58 | Method: post 59 | 60 | Outputs: 61 | SubmitFormFunction: 62 | Description: "Lambda Function ARN" 63 | Value: !GetAtt SubmitFormFunction.Arn 64 | SubmitFormFunctionIamRole: 65 | Description: "Implicit IAM Role created for function" 66 | Value: !GetAtt SubmitFormFunctionRole.Arn 67 | FormDataTable: 68 | Description: DynamoDB Table 69 | Value: !Ref FormDataTable 70 | --------------------------------------------------------------------------------