-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
102 lines (93 loc) · 2.64 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
AWSTemplateFormatVersion: 2010-09-09
Description: Layerless ESBuild Example
Transform:
- AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 10
Runtime: nodejs20.x
MemorySize: 768
Handler: index.handler
Environment:
Variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
AWS_ACCOUNT_ID: !Sub ${AWS::AccountId}
POWERTOOLS_SERVICE_NAME: layerless-esbuild-lambda-api
POWERTOOLS_METRICS_NAMESPACE: layerless-esbuild-lambda
Parameters:
CognitoUserPoolId:
Type: 'AWS::SSM::Parameter::Value<String>'
Default: '/andmoredev-auth/CognitoUserPoolId'
CognitoUserPoolArn:
Type: 'AWS::SSM::Parameter::Value<String>'
Default: '/andmoredev-auth/CognitoUserPoolArn'
Resources:
LayerlessESBuildResourceServer:
Type: AWS::Cognito::UserPoolResourceServer
Properties:
UserPoolId: !Ref CognitoUserPoolId
Identifier: !Sub layerless-esbuild
Name: Echo Scopes
Scopes:
- ScopeName: echo
ScopeDescription: Trigger an echo
CognitoTestAutomationClient:
Type: AWS::Cognito::UserPoolClient
DependsOn:
- LayerlessESBuildResourceServer
Properties:
UserPoolId: !Ref CognitoUserPoolId
GenerateSecret: true
AllowedOAuthFlows:
- client_credentials
AllowedOAuthScopes:
- layerless-esbuild/echo
AllowedOAuthFlowsUserPoolClient: true
API:
Type: AWS::Serverless::Api
Properties:
StageName: api
Auth:
DefaultAuthorizer: ClientCognitoAuthorizer
Authorizers:
ClientCognitoAuthorizer:
UserPoolArn: !Ref CognitoUserPoolArn
AuthorizationScopes:
- layerless-esbuild/echo
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: ./openapi.yaml
EchoFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/functions/echo
Events:
EchoEvent:
Type: Api
Properties:
RestApiId: !Ref API
Path: /echo
Method: POST
Policies:
- AWSLambdaBasicExecutionRole
Metadata:
BuildMethod: esbuild
BuildProperties:
Format: esm
Minify: false
OutExtension:
- .js=.mjs
Target: es2020
Sourcemap: false
EntryPoints:
- index.mjs
Banner:
- js=import { createRequire } from 'module'; const require = createRequire(import.meta.url);
External:
- '@aws-sdk/client-secrets-manager'
Outputs:
ApiURL:
Description: API URL
Value: !Sub https://${API}.execute-api.${AWS::Region}.amazonaws.com/api