Skip to content

Instantly share code, notes, and snippets.

@teyckmans
Created April 2, 2024 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teyckmans/244dff3adcbe292764808b3aa7362c13 to your computer and use it in GitHub Desktop.
Save teyckmans/244dff3adcbe292764808b3aa7362c13 to your computer and use it in GitHub Desktop.
Makes it possible to deploy an SST app with plain CDK
/* eslint-disable */
import { App } from 'sst/constructs';
import { initProject, useProject } from 'sst/project.js';
export const sstCdkBridgeCreateApp = async (): Promise<void> => {
const stage = process.env['SST_STAGE']!;
console.log(`STAGE: ${stage}`);
await initProject({
stage,
});
const project = useProject();
const app = new App({
stage,
name: project.config.name,
region: project.config.region,
mode: 'deploy',
isActiveStack: () => true,
});
const { Stacks } = await import('../node_modules/sst/stacks/index.js');
const [_metafile, sstConfig] = await Stacks.load(project.paths.config);
await resolve(sstConfig.stacks(app));
await app.finish();
};
async function resolve<T>(possiblePromise: Promise<T> | T): Promise<T> {
if (possiblePromise instanceof Promise) {
return await Promise.resolve(possiblePromise);
} else {
return possiblePromise;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment