require 'aws-sdk' require 'net/http' require 'uri' require 'json' # Lambdaのエントリーポイント def lambda_handler(event:, context:) fetch_cost .then { |response| pretty_response(response) } .then { |message| notify_slack(message) } # 一応HTTPレスポンスとして返す { statusCode: 200, body: 'ok' } end # 請求情報の取得 def fetch_cost(time = Time.now) # 認証は既にすんでるのでcredentialsいらない(後述) client = Aws::CostExplorer::Client.new(region: '

