2026-07-07 06:14:06 -03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
import { App, Tags } from "aws-cdk-lib";
|
|
|
|
|
import { FrontendStack } from "../lib/frontend-stack";
|
|
|
|
|
|
|
|
|
|
const app = new App();
|
|
|
|
|
|
|
|
|
|
// Defaults match the dev setup; override via `-c key=value` on the CLI.
|
|
|
|
|
const envName = app.node.tryGetContext("envName") ?? "dev";
|
|
|
|
|
const githubRepo = app.node.tryGetContext("githubRepo") ?? "Sea-Haven-Industries/shoc-frontend-new";
|
|
|
|
|
const deployBranch = app.node.tryGetContext("deployBranch") ?? "dev";
|
2026-08-28 11:59:55 -03:00
|
|
|
// When set (e.g. "staging"), the deploy role trusts the exact GitHub
|
|
|
|
|
// environment OIDC subject instead of a deploy-branch ref. Empty = dev-style
|
|
|
|
|
// branch-ref trust.
|
|
|
|
|
const githubEnvironment = app.node.tryGetContext("githubEnvironment") ?? "";
|
2026-07-07 06:14:06 -03:00
|
|
|
|
|
|
|
|
// Custom domain. Comma-separated, e.g. -c domainNames=dev.seahaven.com
|
|
|
|
|
// The ACM cert MUST be in us-east-1 in the SAME account this stack deploys to.
|
|
|
|
|
const domainNames = (app.node.tryGetContext("domainNames") ?? "")
|
|
|
|
|
.split(",")
|
|
|
|
|
.map((d: string) => d.trim())
|
|
|
|
|
.filter((d: string) => d.length > 0);
|
|
|
|
|
const certificateArn = app.node.tryGetContext("certificateArn") ?? "";
|
|
|
|
|
|
|
|
|
|
// Route 53 hosted zone (this account) for the custom-domain alias record.
|
|
|
|
|
const hostedZoneId = app.node.tryGetContext("hostedZoneId") ?? "";
|
|
|
|
|
const hostedZoneName = app.node.tryGetContext("hostedZoneName") ?? "";
|
|
|
|
|
|
2026-09-10 19:15:11 -04:00
|
|
|
// Terraform adoption safety mode (see infra/cdk/README.md). Adds the required
|
|
|
|
|
// ManageSiteInfrastructure parameter and Retain policies on the transferred
|
|
|
|
|
// resources. Off by default so ordinary synthesis is unchanged.
|
|
|
|
|
const retainForTerraformAdoption =
|
|
|
|
|
String(app.node.tryGetContext("retainForTerraformAdoption") ?? "false").toLowerCase() === "true";
|
|
|
|
|
|
2026-08-28 11:59:55 -03:00
|
|
|
// Staging and beyond protect their stacks from accidental deletion; dev
|
|
|
|
|
// stays teardown-friendly (its artifacts are reproducible). CDK applies this
|
|
|
|
|
// at deploy time — it is not part of the synthesized template.
|
|
|
|
|
const terminationProtection = envName !== "dev";
|
|
|
|
|
|
2026-07-07 06:14:06 -03:00
|
|
|
const stack = new FrontendStack(app, `shoc-frontend-${envName}`, {
|
|
|
|
|
envName,
|
|
|
|
|
githubRepo,
|
|
|
|
|
deployBranch,
|
2026-08-28 11:59:55 -03:00
|
|
|
githubEnvironment,
|
|
|
|
|
terminationProtection,
|
2026-07-07 06:14:06 -03:00
|
|
|
domainNames,
|
|
|
|
|
certificateArn,
|
|
|
|
|
hostedZoneId,
|
|
|
|
|
hostedZoneName,
|
2026-09-10 19:15:11 -04:00
|
|
|
retainForTerraformAdoption,
|
2026-07-07 06:14:06 -03:00
|
|
|
env: {
|
|
|
|
|
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
|
|
|
region: process.env.CDK_DEFAULT_REGION ?? "us-east-1",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Tags.of(stack).add("Project", "shoc-frontend");
|
|
|
|
|
Tags.of(stack).add("Environment", envName);
|
|
|
|
|
Tags.of(stack).add("ManagedBy", "cdk");
|