Seth Geoghegan
10/27/2021, 3:08 PMSeth Geoghegan
10/27/2021, 3:12 PMimport DbStack from "./DbStack";
import * as ec2 from '@aws-cdk/aws-ec2';
export default function main(app) {
// Set default props for all functions
app.setDefaultFunctionProps((stack) => ({
runtime: "python3.6",
srcPath: "src",
vpc: ec2.Vpc.fromLookup(stack, 'apiVpc', {
vpcName: process.env.VPC_NAME,
})
}));
// this stack creates an RDS DB within an existing VPC
const dbStack = new DbStack(app,'db-stack');
app.addDefaultFunctionEnv({
DB_URI: dbStack.databaseURI
})
// Create the HTTP API
const api = new sst.Api(this, "Api", {
defaultFunctionProps: {
srcPath: "src",
},
routes: {
"GET /notes": "list.main",
"GET /notes/{id}": "get.main",
"PUT /notes/{id}": "update.main",
},
});
}