Hey, if you add some default env vars in the main ...
# help
r
Hey, if you add some default env vars in the main method in index.ts file can you reference them in the stack files somehow? e.g.
/stacks/index.ts
Copy code
app.setDefaultFunctionProps({
    runtime: lambda.Runtime.NODEJS_14_X,
    environment: {
      SSM_PREFIX: `/${ssmStage}/`,
      SSM_SHARED_PREFIX: `/${ssmStage}/shared/`,
    },
  });
Looking to access the
SSM_PREFIX
in stack definitions, or should I be just passing them in via props?
r
I will let someone more experienced with SST answer this for sure as maybe this is possible, but I am like 99% confident you wont be able to get nice TS completion with that. The functions seem to be disconnected from
defaultFunctionProps
so I am guessing even if you could get them you would end up in the
any
bucket or typing them again anyway 😕
r
yeah that was my thought too, ive created some helper functions instead to get the values. Thanks @Ross Gerbasi
r
Yeah SST is magic, but sometimes just got to stick to the basics 🙂
k
Hi i think in your stack you can use environment. environment: { TABLE_NAME: props.table.tableName }, then in a lambda you can use export const main = handler(async (event) => { const params = { TableName: process.env.TABLE_NAME, hope this helps