Hey guys, quick question; How have you guys handl...
# help
s
Hey guys, quick question; How have you guys handled working with SST within a team, specifically, using DynamoDb tables or S3 buckets in your stack. We have set up .sst to have a stage prefix, but this only seems to apply to lambdas, queues, sns etc and not buckets or tables. Am I missing something or is there a best practice approach to this? Thanks 🙂
o
Yup, include the stage name in your dynamo table name and s3 bucket name, then import them as env variables into your lambda functions (or wherever they get used)
s
Thanks for the response! So do you not include a stage in .sst stage file?
o
We do - that appears in app.stage inside SST, then the table name includes app.stage
Here’s what we do for a utility queue, same idea would work for any resource:
Copy code
import { Duration } from '@aws-cdk/core';
import { App, Queue, Stack } from '@serverless-stack/resources';
import { StackProps } from 'sst-resources/types';

export default class SinkQueueStack extends Stack {
  constructor(app: App, id: string, props: StackProps) {
    super(app, id, props);
    new Queue(this, `${id}-${app.stage}`, {
      sqsQueue: {
        retentionPeriod: Duration.seconds(60), // 60s is the min
      },
    });
  }
}
s
Oh that's nice, thanks for that much appreciated @Omi Chowdhury 👏
t
Hm why do you need to do this?
Is it because you want the resource name itself to follow a format?