-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsst.config.ts
50 lines (45 loc) · 1.24 KB
/
sst.config.ts
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
/// <reference path="./.sst/platform/config.d.ts" />
export default $config({
app(input) {
return {
name: "api-auth-test",
removal: input?.stage === "production" ? "retain" : "remove",
home: "aws",
};
},
async run() {
const api = new sst.aws.ApiGatewayV2("Api");
const authorizerFn = new sst.aws.Function("Authorizer", {
handler: "src/authorizer.handler",
environment: {},
});
const authorizer = new aws.apigatewayv2.Authorizer("APIGWAuthorizer", {
apiId: api.nodes.api.id,
authorizerType: "REQUEST",
authorizerUri: authorizerFn.nodes.function.invokeArn,
identitySources: ["$request.header.Authorization"],
name: "test-authorizer",
authorizerPayloadFormatVersion: "2.0",
authorizerResultTtlInSeconds: 300,
enableSimpleResponses: true,
});
api.route("GET /", {
handler: "src/main.handler",
});
api.route(
"GET /protected",
{
handler: "src/protected.handler",
},
{
transform: {
route: (routeArgs: sst.aws.ApiGatewayV2RouteArgs) => ({
...routeArgs,
authorizationType: "CUSTOM",
authorizerId: authorizer.id,
}),
},
}
);
},
});