
service: 'tcf-test-budget'

provider:
  name: aws
  runtime: python3.7
  profile: 'tcf-test'
  stackName: 'tcf-test-budget'
  region: 'us-east-1'
  stage: ${self:provider.profile}
  deploymentBucket:
    name: ${self:custom.ServerlessBucketName}
    serverSideEncryption: AES256
    blockPublicAccess: true

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

custom:
  CustomerName: tcf
  StageName: test
  # 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 Budgets

    BudgetExample:
      Type: 'AWS::Budgets::Budget'
      Properties:
        Budget:
          BudgetName: '${self:custom.CustomerName}-${self:custom.StageName}-Cost-Budget'
          BudgetLimit:
            Amount: 250
            Unit: USD
          TimeUnit: MONTHLY
          BudgetType: COST
        NotificationsWithSubscribers:
          - Notification:
              NotificationType: FORECASTED
              ComparisonOperator: GREATER_THAN
              Threshold: 49
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
          - Notification:
              NotificationType: FORECASTED
              ComparisonOperator: GREATER_THAN
              Threshold: 99
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
          - Notification:
              NotificationType: ACTUAL
              ComparisonOperator: GREATER_THAN
              Threshold: 49
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
          - Notification:
              NotificationType: ACTUAL
              ComparisonOperator: GREATER_THAN
              Threshold: 99
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
          - Notification:
              NotificationType: FORECASTED
              ComparisonOperator: GREATER_THAN
              Threshold: 149
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
              - SubscriptionType: EMAIL
                Address: awsbudgetalerts@overdrive.co.za
          - Notification:
              NotificationType: ACTUAL
              ComparisonOperator: GREATER_THAN
              Threshold: 149
            Subscribers:
              - SubscriptionType: EMAIL
                Address: Heinrich@overdrive.co.za
              - SubscriptionType: EMAIL
                Address: awsbudgetalerts@overdrive.co.za
              - SubscriptionType: EMAIL
                Address: AWS.Escalations@overdrive.co.za