Austin
03/14/2022, 5:06 PMSeth Geoghegan
03/14/2022, 5:17 PMSeth Geoghegan
03/14/2022, 5:17 PMSeth Geoghegan
03/14/2022, 5:22 PMSharedAuthStack
construct that conditionally creates the UserPool if the stage is set to dev/stage/prod (or whatever long-lived environments you define). If the stage is anything else (an ephemeral development environment, for example), I use the existing dev
User Pool.Seth Geoghegan
03/14/2022, 5:25 PMimport * as cognito from 'aws-cdk-lib/aws-cognito';
const LONG_LIVED_STAGES = ['dev', 'stage', 'prod'];
export default class SharedAuthStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, props?: SharedAuthStackProps) {
super(scope, id, props);
// if you are deploying to an ephemeral stage
if (!LONG_LIVED_STAGES.includes(scope.stage)) {
// import the existing development User Pool ID
const userPoolId = // lookup value from SSM
// import the existing development User Pool ID
// get the development user pool
this.userPool = cognito.UserPool.fromUserPoolId(
this,
'dev-user-pool',
userPoolId
);
return
}
// Create new User Pool
this.userPool = new cognito.UserPool(...)
// Create SSM parameter for the newly created User Pool
new ssm.StringParameter(...)
}
Seth Geoghegan
03/14/2022, 5:26 PMJan Plaček
03/14/2022, 5:30 PMdev
before developers can start using it? Or do you let it create "lazily" by any (developer) stage that needs it?Seth Geoghegan
03/14/2022, 5:47 PMdev
firstSeth Geoghegan
03/14/2022, 5:48 PMsst deploy SharedAuthStack --stage dev
Seth Geoghegan
03/14/2022, 5:49 PMJan Plaček
03/14/2022, 5:52 PMAustin
03/14/2022, 6:02 PMSeth Geoghegan
03/14/2022, 6:04 PMSeth Geoghegan
03/14/2022, 6:05 PMJan Plaček
03/14/2022, 6:07 PMFrank
Frank
dev
before deploying other stages. But you will run into the opposite problem of need to track which stage created (owns) the resource, and make sure that stage does not get removed.Frank