Skip to content

Instantly share code, notes, and snippets.

@5t33
Last active July 6, 2020 23:55
Show Gist options
  • Save 5t33/ca3768320164e75e588aa76f5bae14a3 to your computer and use it in GitHub Desktop.
Save 5t33/ca3768320164e75e588aa76f5bae14a3 to your computer and use it in GitHub Desktop.
service: lambda-api-demo
plugins:
- serverless-offline
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage}
region: us-east-2
tracing:
lambda: true
functions:
DemoLambda:
role: DemoLambdaRole
handler: index.handler
events:
- http:
path: /health_check
method: GET
- http:
path: /respond_400
method: POST
- http:
path: /throw_error
method: GET
resources:
Resources:
DemoLambdaRole:
Type: AWS::IAM::Role
Properties:
Path: /${opt:stage}/demos/lambdaApiDemo/serviceRoles/
RoleName: DemoLambdaRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: DemoLambdaPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/*:*:*'
- Effect: Allow
Action:
- xray:PutTraceSegment
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource: "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment