Skip to content

Commit b87e025

Browse files
- added example of running functions locally with sam local
1 parent 2b35e44 commit b87e025

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"lodash": "^4.17.4",
2727
"mocha": "^4.0.1",
2828
"serverless": "^1.24.1",
29-
"serverless-pseudo-parameters": "^1.2.5"
29+
"serverless-pseudo-parameters": "^1.2.5",
30+
"serverless-sam": "0.0.2"
3031
}
3132
}

serverless.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ service: big-mouth
22

33
plugins:
44
- serverless-pseudo-parameters
5+
- serverless-sam
56

67
provider:
78
name: aws

template.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: 'AWS::Serverless-2016-10-31'
3+
Description: 'SAM template for Serverless framework service: '
4+
Resources:
5+
restaurantsTable:
6+
Type: 'AWS::DynamoDB::Table'
7+
Properties:
8+
TableName: restaurants
9+
AttributeDefinitions:
10+
- AttributeName: name
11+
AttributeType: S
12+
KeySchema:
13+
- AttributeName: name
14+
KeyType: HASH
15+
ProvisionedThroughput:
16+
ReadCapacityUnits: 1
17+
WriteCapacityUnits: 1
18+
GetIndex:
19+
Type: 'AWS::Serverless::Function'
20+
Properties:
21+
Handler: functions/get-index.handler
22+
Runtime: nodejs6.10
23+
CodeUri: >-
24+
/Users/yancui/SourceCode/Personal/manning-aws-lambda-operational-patterns-and-practices/.serverless/big-mouth.zip
25+
MemorySize: 128
26+
Timeout: 3
27+
Policies:
28+
- Effect: Allow
29+
Action: 'dynamodb:scan'
30+
Resource: 'arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/restaurants'
31+
Environment:
32+
Variables:
33+
restaurants_api: https://i3c5h755j0.execute-api.us-east-1.amazonaws.com/dev/restaurants
34+
cognito_user_pool_id: us-east-1_DfuAwa0vB
35+
cognito_client_id: 1tf8pb1s1n53p7u608e7ic5ih8
36+
Events:
37+
Event1:
38+
Type: Api
39+
Properties:
40+
Path: /
41+
Method: get
42+
GetRestaurants:
43+
Type: 'AWS::Serverless::Function'
44+
Properties:
45+
Handler: functions/get-restaurants.handler
46+
Runtime: nodejs6.10
47+
CodeUri: >-
48+
/Users/yancui/SourceCode/Personal/manning-aws-lambda-operational-patterns-and-practices/.serverless/big-mouth.zip
49+
MemorySize: 128
50+
Timeout: 3
51+
Policies:
52+
- Effect: Allow
53+
Action: 'dynamodb:scan'
54+
Resource: 'arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/restaurants'
55+
Environment:
56+
Variables:
57+
restaurants_table: restaurants
58+
Events:
59+
Event1:
60+
Type: Api
61+
Properties:
62+
Path: /restaurants/
63+
Method: get
64+
Aws_iamResourcePolicy:
65+
Type: 'AWS::Lambda::Permission'
66+
Properties:
67+
Action: 'lambda:InvokeFunction'
68+
FunctionName:
69+
'Fn::GetAtt':
70+
- Aws_iam
71+
- Arn
72+
Principal: apigateway.amazonaws.com
73+
SourceAccount:
74+
Ref: 'AWS::AccountId'
75+
SearchRestaurants:
76+
Type: 'AWS::Serverless::Function'
77+
Properties:
78+
Handler: functions/search-restaurants.handler
79+
Runtime: nodejs6.10
80+
CodeUri: >-
81+
/Users/yancui/SourceCode/Personal/manning-aws-lambda-operational-patterns-and-practices/.serverless/big-mouth.zip
82+
MemorySize: 128
83+
Timeout: 3
84+
Policies:
85+
- Effect: Allow
86+
Action: 'dynamodb:scan'
87+
Resource: 'arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/restaurants'
88+
Environment:
89+
Variables:
90+
restaurants_table: restaurants
91+
Events:
92+
Event1:
93+
Type: Api
94+
Properties:
95+
Path: /restaurants/search
96+
Method: post

0 commit comments

Comments
 (0)