Skip to content

Instantly share code, notes, and snippets.

@pacarvalho
Created June 12, 2022 18:32
Show Gist options
  • Save pacarvalho/2e635dd327586f87e5ad1a6a157fabc0 to your computer and use it in GitHub Desktop.
Save pacarvalho/2e635dd327586f87e5ad1a6a157fabc0 to your computer and use it in GitHub Desktop.
Medium - Serverless Form - template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
serverless-form
SAM project for serverless-form
Parameters:
LambdaVersion:
Default: "not-specified"
Description: "What is the current code version?"
Type: String
Resources:
FormSubmissionFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: index.handler
Runtime: nodejs12.x
MemorySize: 128
Timeout: 3
Environment:
Variables:
LAMBDA_VERSION: !Ref LambdaVersion
Policies:
- AWSLambdaBasicExecutionRole
- Version: "2012-10-17" # Policy Document
Statement:
- Effect: Allow
Action:
- ses:SendEmail
- ses:SendRawEmail
Resource: "*"
Events:
APIRoot:
Type: Api
Properties:
Path: /
Method: POST
RestApiId: !Ref FormSubmissionApi
FormSubmissionApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Cors:
AllowMethods: "'POST'"
AllowOrigin: "'https://my-domain.com'"
AllowHeaders: "'x-requested-with'"
Outputs:
FormSubmissionApi:
Description: "API Gateway endpoint URL"
Value: !Sub "https://${FormSubmissionApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
FormSubmissionFunction:
Description: "Lambda Function ARN"
Value: !GetAtt FormSubmissionFunction.Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment