-
Notifications
You must be signed in to change notification settings - Fork 1
/
app-composer-demo.yaml
217 lines (213 loc) · 6.43 KB
/
app-composer-demo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
Transform: AWS::Serverless-2016-10-31
Parameters:
CodeBucketName:
Type: String
Default: my-bucket
Description: Bucket containing lambda code
Resources:
Api:
Type: AWS::Serverless::Api
Properties:
Name: !Sub
- ${ResourceName} From Stack ${AWS::StackName}
- ResourceName: Api
StageName: Prod
DefinitionBody:
openapi: '3.0'
info: {}
paths:
/items:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ListItems.Arn}/invocations
responses: {}
post:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CreateItem.Arn}/invocations
responses: {}
/items/{id}:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetItem.Arn}/invocations
responses: {}
put:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${UpdateItem.Arn}/invocations
responses: {}
delete:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${DeleteItem.Arn}/invocations
responses: {}
EndpointConfiguration: REGIONAL
TracingEnabled: true
Items:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: id
KeyType: HASH
ListItems:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-ListItems
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: ListItems
CodeUri:
Bucket: !Ref CodeBucketName
Key: "app-composer-demo/CreateItem.zip"
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 1024
Timeout: 30
Tracing: Active
Events:
ApiGETitems:
Type: Api
Properties:
Path: /items
Method: GET
RestApiId: !Ref Api
Environment:
Variables:
ITEMS_TABLE_NAME: !Ref Items
Policies:
- DynamoDBReadPolicy:
TableName: !Ref Items
CreateItem:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-CreateItem
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: CreateItem
CodeUri:
Bucket: !Ref CodeBucketName
Key: "app-composer-demo/CreateItem.zip"
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 1024
Timeout: 30
Tracing: Active
Events:
ApiPOSTitems:
Type: Api
Properties:
Path: /items
Method: POST
RestApiId: !Ref Api
Environment:
Variables:
ITEMS_TABLE_NAME: !Ref Items
Policies:
- DynamoDBWritePolicy:
TableName: !Ref Items
GetItem:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-GetItem
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: GetItem
CodeUri:
Bucket: !Ref CodeBucketName
Key: "app-composer-demo/CreateItem.zip"
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 1024
Timeout: 30
Tracing: Active
Events:
ApiGETitemsid:
Type: Api
Properties:
Path: /items/{id}
Method: GET
RestApiId: !Ref Api
Environment:
Variables:
ITEMS_TABLE_NAME: !Ref Items
Policies:
- DynamoDBReadPolicy:
TableName: !Ref Items
UpdateItem:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-UpdateItem
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: UpdateItem
CodeUri:
Bucket: !Ref CodeBucketName
Key: "app-composer-demo/CreateItem.zip"
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 1024
Timeout: 30
Tracing: Active
Events:
ApiPUTitemsid:
Type: Api
Properties:
Path: /items/{id}
Method: PUT
RestApiId: !Ref Api
Environment:
Variables:
ITEMS_TABLE_NAME: !Ref Items
Policies:
- DynamoDBWritePolicy:
TableName: !Ref Items
DeleteItem:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub ${AWS::StackName}-DeleteItem
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: DeleteItem
CodeUri:
Bucket: !Ref CodeBucketName
Key: "app-composer-demo/DeleteItem.zip"
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 1024
Timeout: 30
Tracing: Active
Events:
ApiDELETEitemsid:
Type: Api
Properties:
Path: /items/{id}
Method: DELETE
RestApiId: !Ref Api
Environment:
Variables:
ITEMS_TABLE_NAME: !Ref Items
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref Items
#ReservedConcurrentExecutions: 1
Metadata:
AWS::Composer::Groups:
Group:
Label: API Compute
Members:
- ListItems
- CreateItem
- GetItem
- UpdateItem
- DeleteItem