Last active
March 10, 2025 18:31
-
-
Save marcus-sa/25e6d9a120e2282e5b9afe0240541e2e to your computer and use it in GitHub Desktop.
Catalyze TypeScript API iterations for single-tenant deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const project = new PulumiProject('customers'); | |
export const deployCustomers = new Pipeline('deploy-customers', { | |
stages: [ | |
new DeploymentStage('deploy', { atomic: true }) | |
.withEnvironmentGroup(environmentGroups.customers) | |
.forEachEnvironment((environment, stage) => { | |
stage.addStep( | |
new InfrastructureDeployStep('infrastructure', { | |
target: new PulumiLocalStack('stack', { | |
project, | |
}), | |
}), | |
); | |
const databaseMigrationStep = new DatabaseMigrationStep('database', { | |
target: new Database('database'), | |
}); | |
stage.addStep(databaseMigrationStep); | |
stage.addStep( | |
new ApplicationDeployStep('customer', { | |
target: new Application('customer'), | |
rollbackStepsOnFailure: [databaseMigrationStep], | |
}), | |
); | |
}), | |
], | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const customers = new Tenants('customers', | |
// can be remote | |
tenants: [ | |
new Tenant('apple', { | |
variables: {}, | |
}), | |
new Tenant('google', { | |
variables: {}, | |
}), | |
new Tenant('microsoft', { | |
variables: {}, | |
}), | |
], | |
}); | |
const infrastructure = new PulumiProject('customers'); | |
const database = new Database('customer'); | |
const application = new Application('customer'); | |
export const deployCustomers = new Pipeline('deploy-customers'); | |
const deploymentStage = deployCustomers.stage('deploy') | |
.deployment({ atomic: true }) | |
.tenants(customers); | |
deploymentStage.tenants.forEach(tenant => { | |
infrastructure.stack(tenant.name).deploy(); | |
const databaseMigration = database.migrate(tenant.name); | |
application.deploy(tenant.name) | |
.rollbackOnFailure({ self: true, steps: [databaseMigration] }); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment