Fatih Erdinç
04/23/2022, 3:44 PMconst api = new sst.Api(this, "Api", {
routes: {
"GET /students": "src/api/get.main",
},
defaultFunctionProps: {
environment: {
BUCKET_NAME: bucket.bucketName,
},
permissions: [bucket],
}
});
this.addOutputs({
"ApiEndpoint": api.url,
});
Frank
x-api-key
? You can get it’s value from the event
object inside ur Lambda function.Fatih Erdinç
04/23/2022, 3:57 PMRoss Coundon
04/23/2022, 4:05 PMFatih Erdinç
04/23/2022, 4:11 PMBrinsley
04/25/2022, 7:18 AMApi
construct as that sits above the v2 (HTTP) ApiGateway, what you want to use instead is the Rest version: ApiGatewayV1Api
Brinsley
04/25/2022, 7:22 AMApi
construct page(s) that mentions the API Key support thing.Frank
Frank
ApiGatewayV1Api
in order to use the built-in API Key feature, ie.
const api = new sst.ApiGatewayApi(...);
const plan = api.cdk.restApi.addUsagePlan('UsagePlan', {
name: 'Easy',
throttle: {
rateLimit: 10,
burstLimit: 2
}
});
const key = api.cdk.restApi.addApiKey('ApiKey');
plan.addApiKey(key);
Frank
Fatih Erdinç
04/29/2022, 12:24 PMimport {HttpLambdaAuthorizer, HttpLambdaResponseType} from "@aws-cdk/aws-apigatewayv2-authorizers-alpha";
const authFunc = new sst.Function(this, "AuthorizerFn", {
handler: "src/functions/authFunction.auth",
})
const lambdaAuthorizer = new HttpLambdaAuthorizer("Authorizer", authFunc, {
identitySource: ["$request.header.X-Api-Key"],
resultsCacheTtl: Duration.seconds(30),
responseTypes: [
HttpLambdaResponseType.SIMPLE
]
});
@Frank @Brinsley