Created
June 19, 2018 02:52
-
-
Save chenrui333/30673fac7c364eeb67279877ba4d0246 to your computer and use it in GitHub Desktop.
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
import json | |
from datadog import initialize, ThreadStats | |
def hello(event, context): | |
initialize() | |
stats = ThreadStats() | |
stats.start() | |
body = { | |
"message": "Go Serverless v1.0! Your function executed successfully!", | |
"input": event | |
} | |
stats.increment('pro.serverless.lambda_python_sample.prod') | |
response = { | |
"statusCode": 200, | |
"body": json.dumps(body["message"]) | |
} | |
return response |
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
{ | |
"name": "serverless-python-sample", | |
"description": "", | |
"version": "0.1.0", | |
"dependencies": {}, | |
"devDependencies": { | |
"serverless-offline-python": "^3.21.2", | |
"serverless-python-requirements": "^4.0.4" | |
} | |
} |
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
datadog |
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: serverless-python-sample | |
# sls version | |
frameworkVersion: ">=1.27.0 < 2.0.0" | |
provider: | |
name: aws | |
runtime: python3.6 | |
stage: local | |
region: us-east-1 | |
iamRoleStatements: | |
- Effect: "Allow" | |
Action: | |
- ssm:GetParameter | |
Resource: | |
- "arn:aws:ssm:us-east-1:123:parameter/pro/datadog-api-key" | |
- "arn:aws:ssm:us-east-1:123:parameter/pro/datadog-app-key" | |
- Effect: "Allow" | |
Action: | |
- kms:Decrypt | |
Resource: "arn:aws:kms:us-east-1:123:key/321" | |
plugins: | |
- serverless-offline-python | |
- serverless-python-requirements | |
custom: | |
stage: "${opt:stage, self:provider.stage}" | |
prod: | |
events: | |
- http: | |
method: GET | |
path: /hello | |
local: | |
events: | |
- http: | |
method: GET | |
path: /hello | |
serverless-offline: | |
port: 4000 | |
functions: | |
hello: | |
handler: handler.hello | |
environment: | |
DATADOG_API_KEY: ${ssm:/pro/datadog-api-key~true} | |
DATADOG_APP_KEY: ${ssm:/pro/datadog-app-key~true} | |
events: ${self:custom.${self:custom.stage}.events} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment