-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
107 lines (101 loc) · 2.93 KB
/
Copy pathtemplate.yaml
File metadata and controls
107 lines (101 loc) · 2.93 KB
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-ts-powertools-app
Sample SAM Template for sam-ts-powertools-app
Globals:
Api:
OpenApiVersion: 3.0.2
TracingEnabled: true
Function:
Handler: app.lambdaHandler
Runtime: nodejs20.x
Architectures:
- arm64
Timeout: 30
MemorySize: 128
Tracing: Active
LoggingConfig:
LogFormat: JSON
Environment:
Variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
AWS_XRAY_CONTEXT_MISSING: 'LOG_ERROR'
POWERTOOLS_LOG_LEVEL: DEBUG
POWERTOOLS_METRICS_NAMESPACE: sam-ts-powertools-app
POWERTOOLS_SERVICE_NAME: helloWorld
POWERTOOLS_TRACER_CAPTURE_HTTPS_REQUESTS: true
POWERTOOLS_TRACER_CAPTURE_RESPONSE: true
Resources:
GreetingTable:
Type: AWS::Serverless::SimpleTable
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
TableName: !Sub ${AWS::StackName}-Workshop
PrimaryKey:
Name: PK
Type: String
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
GetGreetingFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./
Environment:
Variables:
TABLE_NAME: !Ref GreetingTable
Events:
Greeting:
Type: Api
Properties:
# RestApiId: !Ref MainApi
Path: /greeting/{country}
Method: get
RequestParameters:
- method.request.path.id:
Required: true
Policies:
- DynamoDBReadPolicy:
TableName: !Ref GreetingTable
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: es2020
# Sourcemap: true # Enabling source maps will create the required NODE_OPTIONS environment variables on your lambda function during sam build
EntryPoints:
- src/function/get-greeting/app.ts
PutGreetingFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./
Environment:
Variables:
TABLE_NAME: !Ref GreetingTable
Events:
Greeting:
Type: Api
Properties:
Path: /greeting/{country}
Method: put
RequestParameters:
- method.request.path.id:
Required: true
Policies:
- DynamoDBWritePolicy:
TableName: !Ref GreetingTable
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: es2020
EntryPoints:
- src/function/put-greeting/app.ts
Outputs:
# HelloWorldApi:
# Description: API Gateway endpoint URL for Prod stage for Hello World function
# Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
GetGreetingFunction:
Description: Hello World Lambda Function ARN
Value: !GetAtt GetGreetingFunction.Arn