Skip to content

Commit 1642f99

Browse files
author
Jun Fritz
committed
Modified 6 resources:
Updated function resource getItems Updated function resource newItem Updated api resource QuickstartAPI Updated table resource Items Updated facet resource QuickstartAPIFacetrouteMethodGETPath/items Updated facet resource QuickstartAPIFacetrouteMethodPOSTPath/newItem
1 parent 39f74b6 commit 1642f99

File tree

9 files changed

+166
-3
lines changed

9 files changed

+166
-3
lines changed

src/getItems/.stackery-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function-id: getItems
2+
template-path: ../../template.yaml

src/getItems/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
This Function was generated by [Stackery.io](https://www.stackery.io).
3+
4+
We recommend updating this readme with your own function specific documentation.
5+
6+
# Dependencies
7+
You can add dependencies on other files and packages.
8+
Within this directory, local dependencies can be added as individual files and
9+
package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json).
10+
Package dependencies will be installed when the stack is deployed.
11+
12+
# Stackery Documentation
13+
Documentation for Function resources can be found at [https://docs.stackery.io/docs/api/nodes/Function](https://docs.stackery.io/docs/api/nodes/Function/).

src/getItems/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exports.handler = async (event, context) => {
2+
// Log the event argument for debugging and for use in local development.
3+
console.log(JSON.stringify(event, undefined, 2));
4+
5+
return {};
6+
};

src/getItems/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "function",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"aws-sdk": "~2"
6+
}
7+
}

src/newItem/.stackery-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function-id: newItem
2+
template-path: ../../template.yaml

src/newItem/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
This Function was generated by [Stackery.io](https://www.stackery.io).
3+
4+
We recommend updating this readme with your own function specific documentation.
5+
6+
# Dependencies
7+
You can add dependencies on other files and packages.
8+
Within this directory, local dependencies can be added as individual files and
9+
package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json).
10+
Package dependencies will be installed when the stack is deployed.
11+
12+
# Stackery Documentation
13+
Documentation for Function resources can be found at [https://docs.stackery.io/docs/api/nodes/Function](https://docs.stackery.io/docs/api/nodes/Function/).

src/newItem/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exports.handler = async (event, context) => {
2+
// Log the event argument for debugging and for use in local development.
3+
console.log(JSON.stringify(event, undefined, 2));
4+
5+
return {};
6+
};

src/newItem/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "function",
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"aws-sdk": "~2"
6+
}
7+
}

template.yaml

Lines changed: 110 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,110 @@
1-
AWSTemplateFormatVersion: '2010-09-09'
2-
Transform: 'AWS::Serverless-2016-10-31'
3-
Resources: {}
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Transform: AWS::Serverless-2016-10-31
3+
Resources:
4+
QuickstartAPI:
5+
Type: AWS::Serverless::Api
6+
Properties:
7+
Name: !Sub
8+
- ${ResourceName} From Stack ${StackTagName} Environment ${EnvironmentTagName}
9+
- ResourceName: QuickstartAPI
10+
StageName: !Ref EnvironmentAPIGatewayStageName
11+
DefinitionBody:
12+
swagger: '2.0'
13+
info: {}
14+
paths:
15+
/items:
16+
get:
17+
x-amazon-apigateway-integration:
18+
httpMethod: POST
19+
type: aws_proxy
20+
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${getItems.Arn}/invocations
21+
responses: {}
22+
/newItem:
23+
post:
24+
x-amazon-apigateway-integration:
25+
httpMethod: POST
26+
type: aws_proxy
27+
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${newItem.Arn}/invocations
28+
responses: {}
29+
EndpointConfiguration: REGIONAL
30+
TracingEnabled: true
31+
Cors: '''*'''
32+
getItems:
33+
Type: AWS::Serverless::Function
34+
Properties:
35+
FunctionName: !Sub ${AWS::StackName}-getItems
36+
Description: !Sub
37+
- Stack ${StackTagName} Environment ${EnvironmentTagName} Function ${ResourceName}
38+
- ResourceName: getItems
39+
CodeUri: src/getItems
40+
Handler: index.handler
41+
Runtime: nodejs8.10
42+
MemorySize: 3008
43+
Timeout: 300
44+
Tracing: Active
45+
Policies:
46+
- AWSXrayWriteOnlyAccess
47+
- DynamoDBCrudPolicy:
48+
TableName: !Ref Items
49+
Events:
50+
QuickstartAPIGETitems:
51+
Type: Api
52+
Properties:
53+
Path: /items
54+
Method: GET
55+
RestApiId: !Ref QuickstartAPI
56+
Environment:
57+
Variables:
58+
TABLE_NAME: !Ref Items
59+
TABLE_ARN: !GetAtt Items.Arn
60+
newItem:
61+
Type: AWS::Serverless::Function
62+
Properties:
63+
FunctionName: !Sub ${AWS::StackName}-newItem
64+
Description: !Sub
65+
- Stack ${StackTagName} Environment ${EnvironmentTagName} Function ${ResourceName}
66+
- ResourceName: newItem
67+
CodeUri: src/newItem
68+
Handler: index.handler
69+
Runtime: nodejs10.x
70+
MemorySize: 3008
71+
Timeout: 299
72+
Tracing: Active
73+
Policies:
74+
- AWSXrayWriteOnlyAccess
75+
- DynamoDBCrudPolicy:
76+
TableName: !Ref Items
77+
Events:
78+
QuickstartAPIPOSTnewItem:
79+
Type: Api
80+
Properties:
81+
Path: /newItem
82+
Method: POST
83+
RestApiId: !Ref QuickstartAPI
84+
Environment:
85+
Variables:
86+
TABLE_NAME: !Ref Items
87+
TABLE_ARN: !GetAtt Items.Arn
88+
Items:
89+
Type: AWS::DynamoDB::Table
90+
Properties:
91+
AttributeDefinitions:
92+
- AttributeName: id
93+
AttributeType: S
94+
BillingMode: PAY_PER_REQUEST
95+
KeySchema:
96+
- AttributeName: id
97+
KeyType: HASH
98+
StreamSpecification:
99+
StreamViewType: NEW_AND_OLD_IMAGES
100+
TableName: !Sub ${AWS::StackName}-Items
101+
Parameters:
102+
StackTagName:
103+
Type: String
104+
Description: Stack Name (injected by Stackery at deployment time)
105+
EnvironmentTagName:
106+
Type: String
107+
Description: Environment Name (injected by Stackery at deployment time)
108+
EnvironmentAPIGatewayStageName:
109+
Type: String
110+
Description: Environment name used for API Gateway Stage names (injected by Stackery at deployment time)

0 commit comments

Comments
 (0)