Pål Brattberg
03/01/2021, 8:12 PMApi
construct: I'm defining my full application spread out in multiple services, each with their own sst-stack.js
file that is replacing my old serverless.yml
files. I also have some common functions they use.
In order to have all my routes use the same custom domain, it seems it would be smart to use a single Api and have each service add their routes to it. I didn't see any support for adding to the construct outside the constructor but wanted to check - is this supported? Does it sound like a reasonable idea? Does this move beyond your plans for SST and would be better handled in native CDK?Frank
const { httpApi } = new sst.Api(...);
this.httpApi = httpApi;
In index.js
pass httpApi to stackB:
const stackA = new StackA(...);
new StackB(app, "StackB", {
httpApi: stackA.httpApi
});
Then in stackB:
new sst.Api(this, "Api", {
httpApi: props.httpApi,
routes: { ... }
});
Frank
Pål Brattberg
03/02/2021, 2:30 PM[Error at /test-peasy-cognito/CommonApi] Found zones: [] for dns:<http://mydomain.com|mydomain.com>, privateZone:undefined, vpcId:undefined, but wanted exactly 1 zone
I already have other mappings to this same domain, so I'm sure it's something in AWS, just tricky to find the correct magic spell. Was hoping I could create new mapping just by using a different path:
this.apiV2p1 = new sst.Api(this, 'CommonApi', {
customDomain: {
domainName: scope.stage === 'production' ? '<http://v2.api.mydomain.com|v2.api.mydomain.com>' : `${scope.stage}.<http://api.mydomain.com|api.mydomain.com>`,
hostedZone: '<http://mydomain.com|mydomain.com>',
path: 'v2.1'
},
routes: {
'GET /ping': 'resources/domains/handler.ping'
}
})
Also notices I must have routes defined, not possible to just create an Api without routes firstFrank
Frank
Pål Brattberg
03/03/2021, 9:13 AMFrank
Frank
stackA.api
to stackB, then call api.addRoutes
in stackB.
Let me know if this makes sense.Pål Brattberg
03/09/2021, 11:24 PM