Ross Coundon
04/03/2021, 6:54 AMFrank
sst.Api
expects an HTTP API.
Instead, if you are fine with using HTTP API, you can create an sst.Api
in SST and migrate route by route over from ur existing REST API. But you mentioned you are actually using the usage plan and api key features, so I guess this won’t work for you.
If that’s the case, let’s add REST API support in SST. Defining CDK API Gateway constructs isn’t the end of the world… but very cumbersome. I think I can have something by mid next week. Does that work for you timeline wise?Ross Coundon
04/03/2021, 8:28 AMFrank
Frank
Ross Coundon
04/03/2021, 8:33 AMFrank
Frank
sst.ApiGatewayV1Api
Frank
restApiId
and rootResourceId
of your API. And if you are adding more routes in SST, you need to also import the parent paths.
new sst.ApiGatewayV1Api(this, "Api", {
restApi: apigateway.fromRestApiAttributes(this, "IRestApi", {
restApiId,
rootResourceId,
}),
importedPaths: {
"/notes": "slx2bn",
},
routes: {
"GET /notes/{noteId}": "src/getNote.main",
"UPDATE /notes/{noteId}": "src/updateNote.main",
},
});
Frank
Ross Coundon
04/09/2021, 8:55 AMRoss Coundon
04/09/2021, 9:06 AMnew ApiGatewayV1Api(this, "Api", {
restApi: apigateway.fromRestApiAttributes(this, "MyRestApi", {
restApiId,
rootResourceId,
}),
importedPaths: {
"/notes": "slx2bn",
"/users": "uu8xs3",
},
routes: {
"GET /notes/{noteId}": "src/getNote.main",
"GET /users/{userId}": "src/getUser.main",
},
});
I assume the restApiId would be the Id that takes the form of something like ‘d4txxxxxxx’ but what is the rootResourceId?
Also, what do slx2bn and uu8xs3 refer to in the example is it related to what you’d see in the console here?Frank
wil2fry
is equivalent to slx2bn
in the exampleRoss Coundon
04/09/2021, 9:14 AMFrank
serverless.yml
to have these values printed out as stack output and optionally export them
resources:
- Outputs:
ApiGatewayRestApiId:
Value:
Ref: ApiGatewayRestApi
ApiGatewayRestApiRootResourceId:
Value:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
ApiGatewayRestApiNotesResourceId:
Value:
Ref: ApiGatewayResourceNotes
Ross Coundon
04/09/2021, 9:18 AMFrank
/
is the root
/notes
is a child of /
/users
is another child of /
/notes/${noteId}
is a child of /notes
/notes/${noteId}/authors
is a child of /notes/${noteId}
Frank
Frank
importedPaths
is for.Ross Coundon
04/09/2021, 9:22 AM