Skip to content

Instantly share code, notes, and snippets.

@marcus-sa
Last active March 10, 2025 18:31
Show Gist options
  • Save marcus-sa/25e6d9a120e2282e5b9afe0240541e2e to your computer and use it in GitHub Desktop.
Save marcus-sa/25e6d9a120e2282e5b9afe0240541e2e to your computer and use it in GitHub Desktop.
Catalyze TypeScript API iterations for single-tenant deployments
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],
}),
);
}),
],
});
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