Final deployment

To deploy our app we need to go through few steps:

  1. cd sls_app (you should be already there)

  2. sls deploy - this will deploy our app to AWS and output API Gateway endpoint

    endpoint
  3. Enable Slack Interactive Components

Enabling Slack Interactive Components

  1. Navigate to https://api.slack.com/apps

  2. Click on your application

  3. Features -> Interactive Components

  4. Set interactive components to On

    interactive button
  5. Fill in the endpoint URL

    interactive endpoint
  6. Hit the Save Changes button

Local invocation

Because our Cloud Watch events are disabled to prevent unwanted executions before the production/test stage.

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  scheduled-events:
    handler: standup_bot/scheduled.lambda_handler
    events:
      - schedule:
          description: 'Send questions'
#          rate: cron(0 8 ? * MON-FRI *)  # Mo-Fri 8:00
          rate: rate(5 minutes)  # For testing
          enabled: false
          inputTransformer:
            inputPathsMap:
              eventTime: "$.time"
              source: "$.source"
            inputTemplate: '{"source": <source>,"time": <eventTime>,"type": "send_questions"}'
      - schedule:
          description: 'Send report.'
#          rate: cron(0 10 ? * MON-FRI *)  # Mo-Fri 10:00
          rate: rate(5 minutes)  # For testing
          enabled: false
          inputTransformer:
            inputPathsMap:
              eventTime: "$.time"
              source: "$.source"
            inputTemplate: '{"source": <source>,"time": <eventTime>,"type": "send_report"}'

You may have noticed that rate is set to rate which is CloudWatch scheduled event expression and this is also not correct for production, however it’s a good way to observe behaviour triggered by AWS.

For now we invoke our scheduled functions locally and manually via serverless framework commands.

To send_questions run

sls invoke local -f scheduled-events --path example-data/cwe-questions.json

Then take some time to collect the data and once you are ready. Trigger send_report using the command

sls invoke local -f scheduled-events --path example-data/cwe-report.json