<commit_before># stacks/apps/dovetail-marketing-form-handler.yml
# 100A
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Description: >-
  Creates a Lambda function that handles HTML form submissions from the
  Dovetail marketing website

Parameters:
  EnvironmentType: { Type: String }
  EnvironmentTypeAbbreviation: { Type: String }
  RootStackName: { Type: String }
  RootStackId: { Type: String }
  CloudWatchAlarmTaggerServiceToken: { Type: String }
  CloudWatchLogGroupTaggerServiceToken: { Type: String }

Resources:
  FormSubmissionFunction:
    Type: AWS::Serverless::Function
    Properties:
      Description: !Sub >-
        ${EnvironmentType} Dovetail Marketing Website form submissions
      Environment:
        Variables:
          FOO: bar
      Handler: src/index.handler
      InlineCode: |
        exports.handler = async (event, context) => {}
      MemorySize: 128
      # Policies:
      #   - Statement:
      #       - Action: sns:Publish
      #         Effect: Allow
      #         Resource: !Ref PorterJobExecutionSnsTopicArn
      #         Sid: AllowPorterJobPublish
      Runtime: nodejs16.x
      Tags:
        prx:meta:tagging-version: "2021-04-07"
        prx:cloudformation:stack-name: !Ref AWS::StackName
        prx:cloudformation:stack-id: !Ref AWS::StackId
        prx:cloudformation:root-stack-name: !Ref RootStackName
        prx:cloudformation:root-stack-id: !Ref RootStackId
        prx:ops:environment: !Ref EnvironmentType
        prx:dev:family: Dovetail
        prx:dev:application: Marketing Website
      Timeout: 8
  FormSubmissionFunctionLogGroup:
    Type: AWS::Logs::LogGroup
    DeletionPolicy: Delete
    UpdateReplacePolicy: Delete
    Properties:
      LogGroupName: !Sub /aws/lambda/${FormSubmissionFunction}
      RetentionInDays: 14
  FormSubmissionFunctionLogGroupTags:
    Type: Custom::CloudWatchLogGroupTags
    Properties:
      ServiceToken: !Ref CloudWatchLogGroupTaggerServiceToken
      LogGroupName: !Ref FormSubmissionFunctionLogGroup
      Tags:
        - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
        - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
        - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
        - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
        - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
        - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
        - { Key: prx:dev:family, Value: Dovetail }
        - { Key: prx:dev:application, Value: Marketing Website }
  FormSubmissionFunctionElevatedErrorAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: !Sub WARN [Dovetail-Marketing Website] Form submissions <${EnvironmentTypeAbbreviation}> INVOCATIONS ERRORS (${RootStackName})
      AlarmDescription: !Sub >-
        ${EnvironmentType} Dovetail Marketing Website Lambda function is
        failing, so user submissions may not be making it into Zendesk.
      ComparisonOperator: GreaterThanThreshold
      Dimensions:
        - Name: FunctionName
          Value: !Ref FormSubmissionFunction
      EvaluationPeriods: 1
      MetricName: Errors
      Namespace: AWS/Lambda
      Period: 60
      Statistic: Sum
      Threshold: 0
      TreatMissingData: notBreaching
  FormSubmissionFunctionElevatedErrorAlarmTags:
    Type: Custom::CloudWatchAlarmTags
    Properties:
      ServiceToken: !Ref CloudWatchAlarmTaggerServiceToken
      AlarmArn: !GetAtt FormSubmissionFunctionElevatedErrorAlarm.Arn
      Tags:
        - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
        - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
        - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
        - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
        - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
        - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
        - { Key: prx:dev:family, Value: Dovetail }
        - { Key: prx:dev:application, Value: Marketing Website }<commit_msg>Add HTTP API<commit_after># stacks/apps/dovetail-marketing-form-handler.yml
# 100A
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Description: >-
  Creates a Lambda function that handles HTML form submissions from the
  Dovetail marketing website

Parameters:
  EnvironmentType: { Type: String }
  EnvironmentTypeAbbreviation: { Type: String }
  RootStackName: { Type: String }
  RootStackId: { Type: String }
  CloudWatchAlarmTaggerServiceToken: { Type: String }
  CloudWatchLogGroupTaggerServiceToken: { Type: String }

Resources:
  FormSubmissionFunction:
    Type: AWS::Serverless::Function
    Properties:
      Description: !Sub >-
        ${EnvironmentType} Dovetail Marketing Website form submissions
      Environment:
        Variables:
          FOO: bar
      Events:
        PostRequest:
          Properties:
            ApiId: !Ref HttpApi
            Method: post
            Path: /v1/submit
          Type: HttpApi
      Handler: src/index.handler
      InlineCode: |
        exports.handler = async (event, context) => {}
      MemorySize: 128
      # Policies:
      #   - Statement:
      #       - Action: sns:Publish
      #         Effect: Allow
      #         Resource: !Ref PorterJobExecutionSnsTopicArn
      #         Sid: AllowPorterJobPublish
      Runtime: nodejs16.x
      Tags:
        prx:meta:tagging-version: "2021-04-07"
        prx:cloudformation:stack-name: !Ref AWS::StackName
        prx:cloudformation:stack-id: !Ref AWS::StackId
        prx:cloudformation:root-stack-name: !Ref RootStackName
        prx:cloudformation:root-stack-id: !Ref RootStackId
        prx:ops:environment: !Ref EnvironmentType
        prx:dev:family: Dovetail
        prx:dev:application: Marketing Website
      Timeout: 8
  FormSubmissionFunctionLogGroup:
    Type: AWS::Logs::LogGroup
    DeletionPolicy: Delete
    UpdateReplacePolicy: Delete
    Properties:
      LogGroupName: !Sub /aws/lambda/${FormSubmissionFunction}
      RetentionInDays: 14
  FormSubmissionFunctionLogGroupTags:
    Type: Custom::CloudWatchLogGroupTags
    Properties:
      ServiceToken: !Ref CloudWatchLogGroupTaggerServiceToken
      LogGroupName: !Ref FormSubmissionFunctionLogGroup
      Tags:
        - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
        - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
        - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
        - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
        - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
        - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
        - { Key: prx:dev:family, Value: Dovetail }
        - { Key: prx:dev:application, Value: Marketing Website }
  FormSubmissionFunctionElevatedErrorAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: !Sub WARN [Dovetail-Marketing Website] Form submissions <${EnvironmentTypeAbbreviation}> INVOCATIONS ERRORS (${RootStackName})
      AlarmDescription: !Sub >-
        ${EnvironmentType} Dovetail Marketing Website Lambda function is
        failing, so user submissions may not be making it into Zendesk.
      ComparisonOperator: GreaterThanThreshold
      Dimensions:
        - Name: FunctionName
          Value: !Ref FormSubmissionFunction
      EvaluationPeriods: 1
      MetricName: Errors
      Namespace: AWS/Lambda
      Period: 60
      Statistic: Sum
      Threshold: 0
      TreatMissingData: notBreaching
  FormSubmissionFunctionElevatedErrorAlarmTags:
    Type: Custom::CloudWatchAlarmTags
    Properties:
      ServiceToken: !Ref CloudWatchAlarmTaggerServiceToken
      AlarmArn: !GetAtt FormSubmissionFunctionElevatedErrorAlarm.Arn
      Tags:
        - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
        - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
        - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
        - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
        - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
        - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
        - { Key: prx:dev:family, Value: Dovetail }
        - { Key: prx:dev:application, Value: Marketing Website }

  HttpApi:
    Type: AWS::Serverless::HttpApi
    Properties:
      Description: !Sub ${EnvironmentType} Dovetail Marketing Website form API
      Tags:
        prx:meta:tagging-version: "2021-04-07"
        prx:cloudformation:stack-name: !Ref AWS::StackName
        prx:cloudformation:stack-id: !Ref AWS::StackId
        prx:cloudformation:root-stack-name: !Ref RootStackName
        prx:cloudformation:root-stack-id: !Ref RootStackId
        prx:ops:environment: !Ref EnvironmentType
        prx:dev:family: Dovetail
        prx:dev:application: Marketing Website
{'fraction_non_alphanumeric': 0.0959299101696795, 'fraction_numerical': 0.013197294000221804, 'mean_word_length': 3.114051094890511, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2759708', 'n_tokens_mistral': 2802, 'n_tokens_neox': 2669, 'n_words': 595}