Created
April 2, 2024 14:27
-
-
Save teyckmans/244dff3adcbe292764808b3aa7362c13 to your computer and use it in GitHub Desktop.
Makes it possible to deploy an SST app with plain CDK
This file contains 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
/* 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