<@U01JVDKASAC> trying out the "Sharing Auth across...
# sst
@Frank trying out the "Sharing Auth across stacks" example in the documentation. Doing this:
Copy code
const authStack = new AuthStack(app, 'auth');
new ApiStack(app, 'api', { auth: authStack.auth });
Gives me an error message of:
Copy code
Argument of type '{ auth: sst.Auth; }' is not assignable to parameter of type 'StackProps'.
  Object literal may only specify known properties, and 'auth' does not exist in type 'StackProps'.
I'm on sst version
...so, then I tried modifying my stack constructor, and it worked:
Copy code
export default class ApiStack extends sst.Stack {
  constructor(scope: cdk.Construct, id: string, auth: sst.Auth, props?: cdk.StackProps) {
    super(scope, id, props);
bothers me just a hair that I couldn't get it working as written in the example, but reasonably happy.
Hey @Luke Wyman what did you have to change?
I changed the constructor of my derived Stack class to add the
parameter, rather than specify the
in the
. I couldn't get
to recognize an
property. I did get the thing to work, which is what's important at the end of the day. Just trying to scratch this itch as to why my code won't behave like the example.
Ah got it! I just updated the doc to include the TypeScript version of the example https://docs.serverless-stack.com/constructs/Auth#sharing-auth-across-stacks
I also modified the constructor of my AppSyncStack to accept a dynamodb table. I tried sending my table through StackProps but it wasn’t straightforward to figure out how to do that, then how to access the table inside of the stack.
export default class AppSyncStack extends sst.Stack {
constructor( scope: sst.App, id: string, table: sst.Table, props?: sst.StackProps ) { super(scope, id, props); …
Oh I see. That works!
I updated to doc to pass stuff through the
, but for that you’d need to create an interface that extends
with the new
field. It’s definitely more work.