<@U01JVDKASAC> trying out the "Sharing Auth across...
# sst
l
@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
0.35.1
...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.
f
Hey @Luke Wyman what did you have to change?
l
I changed the constructor of my derived Stack class to add the
auth
parameter, rather than specify the
auth
in the
StackProps
. I couldn't get
StackProps
to recognize an
auth
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.
f
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
d
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); …
f
Oh I see. That works!
I updated to doc to pass stuff through the
StackProps
, but for that you’d need to create an interface that extends
sst.StackProps
with the new
table
field. It’s definitely more work.