Created
March 14, 2020 12:09
-
-
Save mattsan/d0a8acf39b5f317c396af9936ec832e6 to your computer and use it in GitHub Desktop.
Ruby で記述した AWS Lambda function を使って idobata に定期的にメッセージを post するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/https' | |
def hello(event:, context:) | |
uri = URI.parse(ENV['IDOBATA_HOOK_URL']) | |
source = event['source'] | |
Net::HTTP.post_form(uri, {source: source}) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: alert | |
provider: | |
name: aws | |
runtime: ruby2.5 | |
stage: dev | |
region: ap-northeast-1 | |
functions: | |
hello: | |
handler: handler.hello | |
environment: | |
IDOBATA_HOOK_URL: ${env:IDOBATA_HOOK_URL} | |
events: | |
# https://serverless.com/framework/docs/providers/aws/events/schedule/ | |
- schedule: | |
rate: cron(0/2 * * * ? *) | |
input: | |
source: 'Hello every 2 min' | |
- schedule: | |
rate: cron(0/3 * * * ? *) | |
input: | |
source: 'Hello every 3 min' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment