Skip to content

Instantly share code, notes, and snippets.

View theburningmonk's full-sized avatar

Yan Cui theburningmonk

View GitHub Profile
path: /
method: get
service: anchor-example
defaultHttp: &defaultHttp
path: /
method: get
provider:
name: aws
runtime: nodejs8.10
functions:
hello-world:
handler: hello-world.handler
stepFunctions:
stateMachines:
myStateMachine:
definition:
StartAt: firstTask
States:
{
"Type": "SubscriptionConfirmation",
"MessageId": "eeb2e742-4746-4bf9-9add-32e45df8bfc1",
"Token": "2336412f37fb687f5d51e6e241dbca52e8c2620f5aa61c0e44f2e34cdac05af6c8d340f1a2314eff0f5dc1ee0f2e949a2fd5aa4f97d5f3e3a428c654a1eb46b096f357977b59f06c8591623d7f102a14d688dcb73291966f6208f2b07037659305f755718536b0b8de10cdb68271266f681ab4c27f6aef458c10f33916b094218854429284d32fdb59aba8fae3caf8e4",
"TopicArn": "arn:aws:sns:us-east-1:374852340823:sns-to-apigw-demo-dev-Topic-1M7QN8DMGC30Z",
"Message": "You have chosen to subscribe to the topic arn:aws:sns:us-east-1:374852340823:sns-to-apigw-demo-dev-Topic-1M7QN8DMGC30Z.\nTo confirm the subscription, visit the SubscribeURL included in this message.",
"SubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-east-1:374852340823:sns-to-apigw-demo-dev-Topic-1M7QN8DMGC30Z&Token=2336412f37fb687f5d51e6e241dbca52e8c2620f5aa61c0e44f2e34cdac05af6c8d340f1a2314eff0f5dc1ee0f2e949a2fd5aa4f97d5f3e3a428c654a1eb46b096f357977b59f0
const Promise = require('bluebird')
const Log = require('@perform/lambda-powertools-logger')
module.exports = () => {
let isTimedOut = undefined
let promise = undefined
const resetPromise = () => {
if (promise) {
promise.cancel()
@theburningmonk
theburningmonk / serverless.yml
Created May 12, 2019 17:24
How to include a SAR application in a Serverless.yml
service: sar-app-in-sls-demo
provider:
name: aws
runtime: nodejs8.10
functions:
hello:
handler: handler.hello
module.exports.handler = co.wrap(function* (event, context, callback) {
let players = lib.genPlayers();
let accept = event.headers.Accept || "application/json";
switch (accept) {
case "application/x-protobuf":
let response = yield protoResponse(players, "functions/player.proto", "protodemo.Players");
callback(null, response);
break;
case "application/json":
deploy:
image: node:latest
environment:
- HOME=/home
volumes:
- .:/src
- $HOME/.aws:/home/.aws
working_dir: /src
command: "./deploy.sh"
#!/usr/bin/env bash
npm install --force
node_modules/.bin/sls deploy
'use strict';
const co = require('co');
const Promise = require('bluebird');
const protobuf = Promise.promisifyAll(require("protobufjs"));
const lib = require('./lib');
const fs = require('fs');
module.exports.handler = co.wrap(function* (event, context, callback) {
console.log(JSON.stringify(event));