Skip to content

Instantly share code, notes, and snippets.

@djheru
Last active January 11, 2020 00:39
Show Gist options
  • Save djheru/8b635cb3d4e0a533734b33f9cba041af to your computer and use it in GitHub Desktop.
Save djheru/8b635cb3d4e0a533734b33f9cba041af to your computer and use it in GitHub Desktop.
23_serverless.yml
service: you-betta-rekognize
package:
individually: true
plugins:
- serverless-bundle
- serverless-pseudo-parameters
custom:
bundle:
sourcemaps: true
caching: false
stats: true
linting: true
apiGatewayUrl:
Fn::Join:
- ''
- - 'https://'
- Ref: ApiGatewayRestApi
- '.execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}'
bucket: ${ssm:/you-betta-rekognize/BUCKET~true}
twitterConsumerAPIKey: ${ssm:/you-betta-rekognize/TWITTER_CONSUMER_API_KEY~true}
twitterConsumerAPIKeySecret: ${ssm:/you-betta-rekognize/TWITTER_CONSUMER_API_KEY_SECRET~true}
twitterAccessToken: ${ssm:/you-betta-rekognize/TWITTER_ACCESS_TOKEN~true}
twitterAccessTokenSecret: ${ssm:/you-betta-rekognize/TWITTER_ACCESS_TOKEN_SECRET~true}
twitterDevEnvironment: youbettarekognize
provider:
name: aws
profile: personal # Or whatever you named your profile when you configured the Serverless CLI
region: ${opt:region, 'us-west-2'}
runtime: nodejs10.x
stage: ${opt:stage, 'dev'}
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:PutObjectAcl
Resource:
- Fn::Join:
- ':'
- - 'arn'
- 'aws'
- 's3'
- ':'
- ${self:custom.bucket}/*
environment:
BUCKET: ${self:custom.bucket}
NODE_ENV: ${self:provider.stage}
API_GATEWAY_URL: ${self:custom.apiGatewayUrl}
TWITTER_CONSUMER_API_KEY: ${self:custom.twitterConsumerAPIKey}
TWITTER_CONSUMER_API_KEY_SECRET: ${self:custom.twitterConsumerAPIKeySecret}
TWITTER_ACCESS_TOKEN: ${self:custom.twitterAccessToken}
TWITTER_ACCESS_TOKEN_SECRET: ${self:custom.twitterAccessTokenSecret}
TWITTER_DEV_ENV: ${self:custom.twitterDevEnvironment}
functions:
customAuthorizer:
handler: src/functions/authorizer.authorize
healthCheck:
handler: src/functions/healthCheck.handler
events:
- http:
path: healthcheck
method: post
# This will run our requests through the authorizer first,
# before hitting the health check function
authorizer: customAuthorizer
getToken:
handler: src/functions/authorizer.getToken
events:
- http:
path: auth/token
method: post
registerWebhook:
handler: src/functions/webhook.register
events:
- http:
path: webhook/register
method: post
authorizer: customAuthorizer
deregisterWebhook:
handler: src/functions/webhook.deregister
events:
- http:
path: webhook/deregister
method: delete
authorizer: customAuthorizer
validateWebhook:
handler: src/functions/webhook.validate
events:
- http:
path: webhook/process
method: get
addSubscription:
handler: src/functions/subscription.add
events:
- http:
path: subscription/add
method: post
authorizer: customAuthorizer
removeSubscription:
handler: src/functions/subscription.remove
events:
- http:
path: subscription/remove
method: delete
authorizer: customAuthorizer
processTweet:
handler: src/functions/webhook.process
events:
- http:
path: webhook/process
method: post
respondToTweet:
handler: src/functions/tweet.respond
events:
- s3:
bucket: ${self:custom.bucket}
event: s3:ObjectCreated:*
existing: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment