Peter Slattery
04/24/2022, 2:59 PMnpx sst build
- I get the following error (followed by a stacktrace I can post if helpful)
Error: Resolution error: Resolution error: Resolution error: Trying to resolve() a Construct at /Resources/${Token[ps-dev-sketching-stack-websocket.websocket-api..connect.Resource.LogicalID.352]}/Properties/environment/variables/table_games_live/node.
If I stop referencing the table across stacks, everything builds just fine - though I can't access the table then.
It seems like this should work, according to docs here: https://docs.serverless-stack.com/advanced/cross-stack-references
I'll post code snippets in the thread.Peter Slattery
04/24/2022, 2:59 PMindex.js
function main(app)
{
let stack_games = new Stack_Games(app, "stack-games", {});
let stack_ws = new Stack_Websocket(app, "stack-websocket", { table: stack_games.table_games_live });
}
Somewhat simplified: Stack_Websocket.js
export class
Stack_Websocket extends sst.Stack
{
constructor(scope, id, props)
{
super(scope, id, props);
let ws = new sst.WebSocketApi(this, "websocket-api", {
defaultFunctionProps: {
environment: { table: props.table },
},
routes: { /* ...omitted for brevity, they work if I omit the environment above */ },
});
ws.attachPermissions([ props.table ]);
this.addOutput({ ApiEndpoint: ws.url });
}
}
thdxr
04/24/2022, 3:00 PMthdxr
04/24/2022, 3:00 PMthdxr
04/24/2022, 3:01 PMPeter Slattery
04/24/2022, 3:02 PMStackContext
in a javascript codebase?Peter Slattery
04/24/2022, 3:07 PMGames_Stack.js
export class
Games_Stack extends sst.Stack
{
table_games_live;
constructor(scope, id, props)
{
super(scope, id, props);
this.table_games_live = new sst.Table(this, "games-live", {
fields: {
systemId: sst.TableFieldType.STRING,
gameId: sst.TableFieldType.STRING,
// more fields all declared this way
},
primaryIndex: {
partitionKey: "systemId",
sortKey: "gameId"
}
});
}
}
thdxr
04/24/2022, 3:07 PMthdxr
04/24/2022, 3:08 PMPeter Slattery
04/24/2022, 3:08 PMPeter Slattery
04/24/2022, 3:08 PMthdxr
04/24/2022, 3:08 PMthdxr
04/24/2022, 3:09 PMPeter Slattery
04/24/2022, 3:10 PMPeter Slattery
04/24/2022, 3:15 PMnpx sst start
and it seems to be working - Thank you for helping!