-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
121 lines (121 loc) · 3.55 KB
/
template.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
Transform: AWS::Serverless-2016-10-31
Resources:
Api:
Type: AWS::Serverless::Api
Properties:
Name: !Sub
- ${ResourceName} From Stack ${AWS::StackName}
- ResourceName: Api
StageName: Prod
DefinitionBody:
openapi: '3.0'
info: {}
paths:
/todos:
get:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetToDos.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/${CreateOrUpdateToDo.Arn}/invocations
responses: {}
/todos/{id}:
put:
x-amazon-apigateway-integration:
httpMethod: POST
type: aws_proxy
uri: !Sub arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${CreateOrUpdateToDo.Arn}/invocations
responses: {}
EndpointConfiguration: REGIONAL
TracingEnabled: true
GetToDos:
Type: AWS::Serverless::Function
Properties:
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: GetToDos
CodeUri: src/list
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 3008
Timeout: 60
Tracing: Active
Environment:
Variables:
TABLE_NAME: !Ref ToDosTable
TABLE_ARN: !GetAtt ToDosTable.Arn
DDB_ENDPOINT_URL: AWS::NoValue
Policies:
- DynamoDBReadPolicy:
TableName: !Ref ToDosTable
Architectures:
- arm64
Events:
ApiGETtodos:
Type: Api
Properties:
Path: /todos
Method: GET
RestApiId: !Ref Api
GetToDosLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Retain
Properties:
LogGroupName: !Sub /aws/lambda/${GetToDos}
ToDosTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: Id
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: Id
KeyType: HASH
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
CreateOrUpdateToDo:
Type: AWS::Serverless::Function
Properties:
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: CreateOrUpdateToDo
CodeUri: src/createOrUpdate
Handler: index.handler
Runtime: nodejs18.x
MemorySize: 3008
Timeout: 30
Tracing: Active
Environment:
Variables:
TABLE_NAME: !Ref ToDosTable
TABLE_ARN: !GetAtt ToDosTable.Arn
DDB_ENDPOINT_URL: AWS::NoValue
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref ToDosTable
Events:
ApiPOSTtodos:
Type: Api
Properties:
Path: /todos
Method: POST
RestApiId: !Ref Api
ApiPUTtodosid:
Type: Api
Properties:
Path: /todos/{id}
Method: PUT
RestApiId: !Ref Api
Architectures:
- arm64
CreateOrUpdateToDoLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Retain
Properties:
LogGroupName: !Sub /aws/lambda/${CreateOrUpdateToDo}