Skip to content

Instantly share code, notes, and snippets.

@mattsan
Created March 14, 2020 12:09
Show Gist options
  • Save mattsan/d0a8acf39b5f317c396af9936ec832e6 to your computer and use it in GitHub Desktop.
Save mattsan/d0a8acf39b5f317c396af9936ec832e6 to your computer and use it in GitHub Desktop.
Ruby で記述した AWS Lambda function を使って idobata に定期的にメッセージを post するサンプル
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
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