
service: 'tcf-prod-sns-tech-note'

provider:
  name: aws
  runtime: python3.7
  profile: 'tcf-prod'
  stackName: 'tcf-prod-sns-tech-note'
  region: 'af-south-1'
  stage: ${self:provider.profile}
  deploymentBucket:
    name: ${self:custom.ServerlessBucketName}
    serverSideEncryption: AES256
    blockPublicAccess: true

plugins:
  - serverless-deployment-bucket
  - serverless-parameters

custom:
  CustomerName: tcf
  StageName: prod
  # Combination of profile and function name used as bucket name:
  ResourceName: serverless-framework # Only lowercase letters and numbers allowed. Used to populate bucket name.
  ServerlessBucketName: '${self:custom.ResourceName}-${self:provider.stage}-${self:provider.region}'
  FlowLogBucketName: '${self:custom.ResourceName}-${self:provider.stage}-${self:provider.region}-flowlog'

  # CloudFormation parameters templates

resources:

  # CloudFormation resource templates

  Resources:

    # Create sns topic
    TechnicalNotificationSNSTopic:
      Type: AWS::SNS::Topic
      Properties:
        TopicName: technical-notifications
        Tags:
          - Key: Name
            Value: !Join
              - '-'
              - - '${self:custom.CustomerName}'
                - '${self:custom.StageName}'
                - 'sns'
                - 'topic'

    # Create subscription

    MySubscription:
      Type: AWS::SNS::Subscription
      Properties:
        Endpoint: peter.fosseus@overdrive.co.za
        Protocol: email
        TopicArn: !Ref 'TechnicalNotificationSNSTopic'

  ## Outputs

  Outputs:
    exportTecnicalNotificationSNSTopic:
      Description: '${self:custom.CustomerName}-${self:custom.StageName} - SNS TechnicalNotification'
      Export:
        Name: '${self:custom.CustomerName}-${self:custom.StageName}-SNSTechnicalNotification'
      Value: !Ref TechnicalNotificationSNSTopic