diff --git a/apps/studio/src/server/modules/aws/buildspec.json b/apps/studio/src/server/modules/aws/buildspec.json new file mode 100644 index 0000000000..637563d20f --- /dev/null +++ b/apps/studio/src/server/modules/aws/buildspec.json @@ -0,0 +1,8 @@ +{ + "version": "0.2", + "phases": { + "build": { + "commands": ["echo \"hello\""] + } + } +} diff --git a/apps/studio/src/server/modules/aws/codebuild.service.ts b/apps/studio/src/server/modules/aws/codebuild.service.ts index bc62bd27c4..ebd16ea284 100644 --- a/apps/studio/src/server/modules/aws/codebuild.service.ts +++ b/apps/studio/src/server/modules/aws/codebuild.service.ts @@ -5,6 +5,9 @@ import { StartBuildCommand, } from "@aws-sdk/client-codebuild" import { ServiceException } from "@aws-sdk/smithy-client" +import * as yaml from "yaml" + +import buildspec from "./buildspec.json" const client = new CodeBuildClient({ region: "ap-southeast-1" }) @@ -61,6 +64,8 @@ export const createCodeBuildProject = async ({ projectId: string siteId: number }): Promise => { + const stringifiedBuildspec = yaml.stringify(buildspec) + /* TODO: Things to add 1. VPC config 2. Default service role @@ -71,8 +76,7 @@ export const createCodeBuildProject = async ({ name: projectId, source: { type: "NO_SOURCE", - buildspec: - 'version: 0.2\n\nphases:\n build:\n commands:\n - echo "hello"\n', + buildspec: stringifiedBuildspec, }, artifacts: { type: "NO_ARTIFACTS", diff --git a/apps/studio/src/server/modules/page/page.router.ts b/apps/studio/src/server/modules/page/page.router.ts index 1861caa4c5..69b0dabad0 100644 --- a/apps/studio/src/server/modules/page/page.router.ts +++ b/apps/studio/src/server/modules/page/page.router.ts @@ -267,10 +267,16 @@ export const pageRouter = router({ siteId, }) } catch (e) { - ctx.logger.error("CodeBuild project creation failure", { + const msg = "CodeBuild project creation failure" + ctx.logger.error(msg, { userId: ctx.user.id, siteId, }) + throw new TRPCError({ + message: msg, + code: "INTERNAL_SERVER_ERROR", + cause: e, + }) } // update site to the newly created codebuild project id @@ -280,7 +286,6 @@ export const pageRouter = router({ // initiate new build await startProjectById(codeBuildId) - return addedVersionResult }), })