is this an ok pattern? (referencing cross-stack in...
# help
s
is this an ok pattern? (referencing cross-stack in CDK)
Copy code
export default function main(app: <http://sst.App|sst.App>): void {
  // Set default runtime for all functions
  app.setDefaultFunctionProps({
    runtime: 'nodejs14.x',
    tracing: Tracing.DISABLED,
  });

  const coreStack = new CoreStack(app, 'core');
  new ApiStack(app, 'api', { cognitoAuth: coreStack.auth });
}
within
CoreStack
constructor, I’m doing
this.auth = auth
(and auth is an instance of
sst.Auth
) lemme know if there’s a better way
t
This is the way I've seen most people do it 👍🏽
s
thanks! do you know the SST/CDK equivalent of
${cf:stackname.outputVar}
in Serverless Framework? or is it not possible?
in other words, is there some way to reference an output variable in a totally different repo & stack
@Sam Hulick I have wondered the same, did not try this out but this might work
This is referring to outputs from serverless framework but I am assuming this could be the same ?
s
hmm. on second thought, this probably doesn’t make sense to do. I was attempting something that’s probably not a good idea 😄 thanks though
j
@Sam Hulick did you end up finding a better pattern for this? i'm in a similar situation, though in this case i've defined a dynamoDB table whose name & arn i'd like to reference in my ApiStack. typescript is throwing a fit passing props to ApiStack, is the only other worry.
t
This probably needs to be documented better but you can extend the props type to include the additional props you'd need
j
thanks, that did the trick. i did eventually find out in another thread that it's explained in the docs here, though i clearly whiffed on finding that bit in the docs.