@lsts_tech/infra 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/bin/init.d.ts +9 -0
- package/dist/bin/init.d.ts.map +1 -0
- package/dist/bin/init.js +315 -0
- package/dist/bin/init.js.map +1 -0
- package/dist/stacks/Dns.d.ts +69 -0
- package/dist/stacks/Dns.d.ts.map +1 -0
- package/dist/stacks/Dns.js +57 -0
- package/dist/stacks/Dns.js.map +1 -0
- package/dist/stacks/ExpoSite.d.ts +72 -0
- package/dist/stacks/ExpoSite.d.ts.map +1 -0
- package/dist/stacks/ExpoSite.js +49 -0
- package/dist/stacks/ExpoSite.js.map +1 -0
- package/dist/stacks/NextSite.d.ts +86 -0
- package/dist/stacks/NextSite.d.ts.map +1 -0
- package/dist/stacks/NextSite.js +60 -0
- package/dist/stacks/NextSite.js.map +1 -0
- package/dist/stacks/Pipeline.d.ts +128 -0
- package/dist/stacks/Pipeline.d.ts.map +1 -0
- package/dist/stacks/Pipeline.js +311 -0
- package/dist/stacks/Pipeline.js.map +1 -0
- package/dist/stacks/index.d.ts +41 -0
- package/dist/stacks/index.d.ts.map +1 -0
- package/dist/stacks/index.js +38 -0
- package/dist/stacks/index.js.map +1 -0
- package/docs/CLI.md +59 -0
- package/docs/CONFIGURATION.md +78 -0
- package/docs/EXAMPLES.md +9 -0
- package/examples/next-and-expo/infra.config.ts +104 -0
- package/examples/next-only/infra.config.ts +60 -0
- package/package.json +102 -0
- package/schemas/pipeline.schema.json +25 -0
- package/scripts/cleanup-orphan-lambdas.sh +102 -0
- package/scripts/delete-amplify-app.sh +50 -0
- package/scripts/ensure-pipelines.sh +144 -0
- package/scripts/ensure-secrets.sh +58 -0
- package/scripts/postdeploy-update-dns.sh +158 -0
- package/scripts/predeploy-checks.sh +192 -0
- package/scripts/pulumi-deploy.sh +29 -0
- package/scripts/sst-deploy.sh +79 -0
- package/templates/buildspec.yml +77 -0
- package/templates/ensure-pipelines.sh +117 -0
- package/templates/env.example +38 -0
- package/templates/infra.config.ts +199 -0
- package/templates/secrets.schema.json +20 -0
- package/templates/sst-env.d.ts +50 -0
- package/templates/sst.config.ts +28 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpoSite — AWS Static Site Construct for Expo Web apps
|
|
3
|
+
*
|
|
4
|
+
* Creates a fast, globally distributed static site using Amazon S3 and CloudFront.
|
|
5
|
+
* Pre-configured for Expo web exports (SPAs).
|
|
6
|
+
*/
|
|
7
|
+
export interface ExpoSiteConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The relative path to the Expo application root.
|
|
10
|
+
* @example "../../apps/mobile"
|
|
11
|
+
*/
|
|
12
|
+
appPath: string;
|
|
13
|
+
/**
|
|
14
|
+
* Domain configuration mapping for the site.
|
|
15
|
+
* Can be a string, or an object specifying aliases.
|
|
16
|
+
* @example "mobile.example.com"
|
|
17
|
+
*/
|
|
18
|
+
domain?: string | {
|
|
19
|
+
name: string;
|
|
20
|
+
dns?: unknown;
|
|
21
|
+
cert?: string;
|
|
22
|
+
aliases?: string[];
|
|
23
|
+
redirects?: string[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* ARN of an existing ACM certificate to reuse instead of creating a new one.
|
|
27
|
+
* Avoids Route53 CNAME conflicts on subsequent deploys.
|
|
28
|
+
* @example "arn:aws:acm:us-east-1:123456789:certificate/abc-123"
|
|
29
|
+
*/
|
|
30
|
+
certificateArn?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Environment variables injected at build time.
|
|
33
|
+
*/
|
|
34
|
+
environment?: Record<string, string | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* CloudFront invalidation configuration.
|
|
37
|
+
*/
|
|
38
|
+
invalidation?: {
|
|
39
|
+
paths?: string[];
|
|
40
|
+
wait?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Expo web build settings.
|
|
44
|
+
* Supports both modern Expo (`dist`) and customized outputs (e.g. `web-build`).
|
|
45
|
+
*/
|
|
46
|
+
build?: {
|
|
47
|
+
command?: string;
|
|
48
|
+
output?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Static site error page.
|
|
52
|
+
* Use `index.html` for SPA-style Expo web routing.
|
|
53
|
+
* @default "index.html"
|
|
54
|
+
*/
|
|
55
|
+
errorPage?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Provide a custom construct ID.
|
|
58
|
+
* @default "ExpoSite"
|
|
59
|
+
*/
|
|
60
|
+
id?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Provisions a StaticSite for an Expo Web application.
|
|
64
|
+
*
|
|
65
|
+
* @param config Configuration options for the Expo site
|
|
66
|
+
* @returns The initialized `sst.aws.StaticSite` instance and the site URL
|
|
67
|
+
*/
|
|
68
|
+
export declare function createExpoSite(config: ExpoSiteConfig): {
|
|
69
|
+
site: any;
|
|
70
|
+
url: any;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=ExpoSite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoSite.d.ts","sourceRoot":"","sources":["../../stacks/ExpoSite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,cAAc;IAC3B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,MAAM,CAAC,EACD,MAAM,GACN;QACI,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;IAER;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAEjD;;OAEG;IACH,YAAY,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IAEF;;;OAGG;IACH,KAAK,CAAC,EAAE;QACJ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc;;;EAqCpD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpoSite — AWS Static Site Construct for Expo Web apps
|
|
3
|
+
*
|
|
4
|
+
* Creates a fast, globally distributed static site using Amazon S3 and CloudFront.
|
|
5
|
+
* Pre-configured for Expo web exports (SPAs).
|
|
6
|
+
*/
|
|
7
|
+
/// <reference path="../sst-env.d.ts" />
|
|
8
|
+
/**
|
|
9
|
+
* Provisions a StaticSite for an Expo Web application.
|
|
10
|
+
*
|
|
11
|
+
* @param config Configuration options for the Expo site
|
|
12
|
+
* @returns The initialized `sst.aws.StaticSite` instance and the site URL
|
|
13
|
+
*/
|
|
14
|
+
export function createExpoSite(config) {
|
|
15
|
+
const constructId = config.id || "ExpoSite";
|
|
16
|
+
const buildCommand = config.build?.command ?? "npx expo export -p web";
|
|
17
|
+
const buildOutput = config.build?.output ?? "dist";
|
|
18
|
+
// If an existing cert ARN is provided, inject it into the domain config so
|
|
19
|
+
// SST/Pulumi skips the ACM certificate + Route53 CNAME validation step.
|
|
20
|
+
let domain = config.domain;
|
|
21
|
+
if (config.certificateArn && domain) {
|
|
22
|
+
if (typeof domain === "string") {
|
|
23
|
+
domain = { name: domain, cert: config.certificateArn };
|
|
24
|
+
}
|
|
25
|
+
else if (typeof domain === "object") {
|
|
26
|
+
domain = { ...domain, cert: config.certificateArn };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const cleanEnv = {};
|
|
30
|
+
for (const [key, value] of Object.entries(config.environment ?? {})) {
|
|
31
|
+
if (value !== undefined) {
|
|
32
|
+
cleanEnv[key] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const site = new sst.aws.StaticSite(constructId, {
|
|
36
|
+
path: config.appPath,
|
|
37
|
+
build: {
|
|
38
|
+
command: buildCommand,
|
|
39
|
+
output: buildOutput,
|
|
40
|
+
},
|
|
41
|
+
domain,
|
|
42
|
+
environment: cleanEnv,
|
|
43
|
+
invalidation: config.invalidation,
|
|
44
|
+
// Expo creates a static SPA with index.html as the entry point
|
|
45
|
+
errorPage: config.errorPage ?? "index.html",
|
|
46
|
+
});
|
|
47
|
+
return { site, url: site.url };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=ExpoSite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoSite.js","sourceRoot":"","sources":["../../stacks/ExpoSite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wCAAwC;AAmExC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACjD,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,IAAI,UAAU,CAAC;IAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,wBAAwB,CAAC;IACvE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,MAAM,CAAC;IAEnD,2EAA2E;IAC3E,wEAAwE;IACxE,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,IAAI,MAAM,CAAC,cAAc,IAAI,MAAM,EAAE,CAAC;QAClC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QAC3D,CAAC;aAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QACxD,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;QAClE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC;IACL,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE;QAC7C,IAAI,EAAE,MAAM,CAAC,OAAO;QACpB,KAAK,EAAE;YACH,OAAO,EAAE,YAAY;YACrB,MAAM,EAAE,WAAW;SACtB;QACD,MAAM;QACN,WAAW,EAAE,QAAQ;QACrB,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,YAAY;KAC9C,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NextSite — Reusable SST v3 Next.js Site Construct
|
|
3
|
+
*
|
|
4
|
+
* Wraps `sst.aws.Nextjs` with opinionated defaults for monorepo deployments.
|
|
5
|
+
* Handles OpenNext bundling, CloudFront distribution, Lambda functions for SSR,
|
|
6
|
+
* and S3 for static assets.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createNextSite } from "@lsts_tech/infra/stacks/NextSite";
|
|
11
|
+
*
|
|
12
|
+
* const site = createNextSite({
|
|
13
|
+
* appPath: "../../apps/web",
|
|
14
|
+
* domain: "example.com",
|
|
15
|
+
* environment: { DATABASE_URL: databaseUrl.value },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface NextSiteConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Relative path from packages/infra to the Next.js app directory.
|
|
22
|
+
* @example "../../apps/web"
|
|
23
|
+
*/
|
|
24
|
+
appPath: string;
|
|
25
|
+
/**
|
|
26
|
+
* The custom domain configuration.
|
|
27
|
+
* Can be a string like "example.com" or a full domain config object.
|
|
28
|
+
*/
|
|
29
|
+
domain?: string | {
|
|
30
|
+
name: string;
|
|
31
|
+
dns?: unknown;
|
|
32
|
+
cert?: string;
|
|
33
|
+
aliases?: string[];
|
|
34
|
+
redirects?: string[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* ARN of an existing ACM certificate to reuse instead of creating a new one.
|
|
38
|
+
* Avoids Route53 CNAME conflicts on subsequent deploys.
|
|
39
|
+
* @example "arn:aws:acm:us-east-1:123456789:certificate/abc-123"
|
|
40
|
+
*/
|
|
41
|
+
certificateArn?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Environment variables to inject into the Next.js app at build/runtime.
|
|
44
|
+
* Secrets should be referenced via `sst.Secret` values.
|
|
45
|
+
*/
|
|
46
|
+
environment?: Record<string, string | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to enable WAF (Web Application Firewall) on the CloudFront distribution.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
waf?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom invalidation paths after deployment.
|
|
54
|
+
* @default ["/*"]
|
|
55
|
+
*/
|
|
56
|
+
invalidation?: {
|
|
57
|
+
paths?: string[];
|
|
58
|
+
wait?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Warm the Lambda functions to reduce cold starts.
|
|
62
|
+
* Set to the number of concurrent warm instances.
|
|
63
|
+
* @default 0 (disabled)
|
|
64
|
+
*/
|
|
65
|
+
warm?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Optional construct id to use when creating the SST construct.
|
|
68
|
+
* This helps produce clearer resource names (included in generated Lambda names).
|
|
69
|
+
* If omitted the default id `Site` is used.
|
|
70
|
+
*/
|
|
71
|
+
id?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates an SST v3 Nextjs site with monorepo-aware defaults.
|
|
75
|
+
*
|
|
76
|
+
* Features:
|
|
77
|
+
* - OpenNext bundling (SSR via Lambda, static via S3+CloudFront)
|
|
78
|
+
* - Middleware support (runs in Lambda@Edge)
|
|
79
|
+
* - API routes (run in Lambda)
|
|
80
|
+
* - Image optimization via Lambda
|
|
81
|
+
*/
|
|
82
|
+
export declare function createNextSite(config: NextSiteConfig): {
|
|
83
|
+
site: any;
|
|
84
|
+
url: any;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=NextSite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextSite.d.ts","sourceRoot":"","sources":["../../stacks/NextSite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAEF;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAEjD;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IAEF;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc;;;EAyCpD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NextSite — Reusable SST v3 Next.js Site Construct
|
|
3
|
+
*
|
|
4
|
+
* Wraps `sst.aws.Nextjs` with opinionated defaults for monorepo deployments.
|
|
5
|
+
* Handles OpenNext bundling, CloudFront distribution, Lambda functions for SSR,
|
|
6
|
+
* and S3 for static assets.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createNextSite } from "@lsts_tech/infra/stacks/NextSite";
|
|
11
|
+
*
|
|
12
|
+
* const site = createNextSite({
|
|
13
|
+
* appPath: "../../apps/web",
|
|
14
|
+
* domain: "example.com",
|
|
15
|
+
* environment: { DATABASE_URL: databaseUrl.value },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/// <reference path="../sst-env.d.ts" />
|
|
20
|
+
/**
|
|
21
|
+
* Creates an SST v3 Nextjs site with monorepo-aware defaults.
|
|
22
|
+
*
|
|
23
|
+
* Features:
|
|
24
|
+
* - OpenNext bundling (SSR via Lambda, static via S3+CloudFront)
|
|
25
|
+
* - Middleware support (runs in Lambda@Edge)
|
|
26
|
+
* - API routes (run in Lambda)
|
|
27
|
+
* - Image optimization via Lambda
|
|
28
|
+
*/
|
|
29
|
+
export function createNextSite(config) {
|
|
30
|
+
const { appPath, domain, environment = {}, warm = 0, invalidation = { paths: ["/*"], wait: true }, id, } = config;
|
|
31
|
+
// Filter out undefined env vars (secrets that may not be set in all stages)
|
|
32
|
+
const cleanEnv = {};
|
|
33
|
+
for (const [key, value] of Object.entries(environment)) {
|
|
34
|
+
if (value !== undefined) {
|
|
35
|
+
cleanEnv[key] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const constructId = id ?? "Site";
|
|
39
|
+
let finalDomain = domain;
|
|
40
|
+
if (config.certificateArn && finalDomain) {
|
|
41
|
+
if (typeof finalDomain === "string") {
|
|
42
|
+
finalDomain = { name: finalDomain, cert: config.certificateArn };
|
|
43
|
+
}
|
|
44
|
+
else if (typeof finalDomain === "object") {
|
|
45
|
+
finalDomain = { ...finalDomain, cert: config.certificateArn };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const site = new sst.aws.Nextjs(constructId, {
|
|
49
|
+
path: appPath,
|
|
50
|
+
environment: cleanEnv,
|
|
51
|
+
domain: finalDomain,
|
|
52
|
+
warm,
|
|
53
|
+
invalidation,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
site,
|
|
57
|
+
url: site.url,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=NextSite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextSite.js","sourceRoot":"","sources":["../../stacks/NextSite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wCAAwC;AAgExC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,EACJ,OAAO,EACP,MAAM,EACN,WAAW,GAAG,EAAE,EAChB,IAAI,GAAG,CAAC,EACR,YAAY,GAAG,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAC5C,EAAE,GACH,GAAG,MAAM,CAAC;IAEX,4EAA4E;IAC5E,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,EAAE,IAAI,MAAM,CAAC;IAEjC,IAAI,WAAW,GAAG,MAAM,CAAC;IACzB,IAAI,MAAM,CAAC,cAAc,IAAI,WAAW,EAAE,CAAC;QACzC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,WAAW,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QACnE,CAAC;aAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC3C,WAAW,GAAG,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE;QAC3C,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,QAAQ;QACrB,MAAM,EAAE,WAAW;QACnB,IAAI;QACJ,YAAY;KACb,CAAC,CAAC;IAEH,OAAO;QACL,IAAI;QACJ,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline — AWS CodePipeline + CodeBuild CI/CD Construct
|
|
3
|
+
*
|
|
4
|
+
* Creates a fully managed CI/CD pipeline using AWS-native services:
|
|
5
|
+
* - CodeStar Connection → GitHub (source)
|
|
6
|
+
* - CodeBuild → builds & deploys via SST
|
|
7
|
+
* - CodePipeline → orchestrates source → build
|
|
8
|
+
*
|
|
9
|
+
* Each pipeline is branch-aware: push to a branch triggers deployment
|
|
10
|
+
* to the corresponding SST stage.
|
|
11
|
+
*
|
|
12
|
+
* Security:
|
|
13
|
+
* - No AWS credentials stored in GitHub
|
|
14
|
+
* - Secrets fetched from SSM Parameter Store at build time
|
|
15
|
+
* - IAM roles scoped per pipeline
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* createPipeline({
|
|
20
|
+
* name: "myapp-prod",
|
|
21
|
+
* repo: "myorg/myapp",
|
|
22
|
+
* branch: "main",
|
|
23
|
+
* stage: "production",
|
|
24
|
+
* region: "us-east-1",
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export interface PipelineConfig {
|
|
29
|
+
/**
|
|
30
|
+
* A unique name for this pipeline (used as resource prefix).
|
|
31
|
+
* @example "myapp-prod"
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* GitHub repository in "owner/repo" format.
|
|
36
|
+
* @example "myorg/myapp"
|
|
37
|
+
*/
|
|
38
|
+
repo: string;
|
|
39
|
+
/**
|
|
40
|
+
* The branch to watch for changes.
|
|
41
|
+
* @example "main" | "develop"
|
|
42
|
+
*/
|
|
43
|
+
branch: string;
|
|
44
|
+
/**
|
|
45
|
+
* The SST stage to deploy to when this branch is pushed.
|
|
46
|
+
* @example "production" | "dev"
|
|
47
|
+
*/
|
|
48
|
+
stage: string;
|
|
49
|
+
/**
|
|
50
|
+
* AWS region for the pipeline resources.
|
|
51
|
+
* @default "us-east-1"
|
|
52
|
+
*/
|
|
53
|
+
region?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Node.js version to use in CodeBuild.
|
|
56
|
+
* @default "22"
|
|
57
|
+
*/
|
|
58
|
+
nodeVersion?: string;
|
|
59
|
+
/**
|
|
60
|
+
* pnpm version to install in CodeBuild.
|
|
61
|
+
* @default "9.15.0"
|
|
62
|
+
*/
|
|
63
|
+
pnpmVersion?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Path to the infra package from the repo root.
|
|
66
|
+
* @default "packages/infra"
|
|
67
|
+
*/
|
|
68
|
+
infraPath?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Additional environment variables for CodeBuild.
|
|
71
|
+
* Secrets should use SSM parameter references.
|
|
72
|
+
*/
|
|
73
|
+
buildEnv?: Record<string, string>;
|
|
74
|
+
/**
|
|
75
|
+
* CodeBuild compute type.
|
|
76
|
+
* @default "BUILD_GENERAL1_MEDIUM"
|
|
77
|
+
*/
|
|
78
|
+
computeType?: "BUILD_GENERAL1_SMALL" | "BUILD_GENERAL1_MEDIUM" | "BUILD_GENERAL1_LARGE";
|
|
79
|
+
/**
|
|
80
|
+
* Build timeout in minutes.
|
|
81
|
+
* @default 30
|
|
82
|
+
*/
|
|
83
|
+
timeoutMinutes?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Optional: existing CodeStar Connection ARN.
|
|
86
|
+
* If not provided, a new connection will be created (requires manual confirmation in AWS Console).
|
|
87
|
+
*/
|
|
88
|
+
codestarConnectionArn?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional: project name tag for resource grouping.
|
|
91
|
+
* Used in resource tags to identify which project owns the resources.
|
|
92
|
+
* @default name prefix (e.g., "myapp")
|
|
93
|
+
*/
|
|
94
|
+
projectTag?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates an AWS CodePipeline with CodeBuild for SST deployments.
|
|
98
|
+
*
|
|
99
|
+
* Architecture:
|
|
100
|
+
* GitHub (push) → CodeStar Connection → CodePipeline → CodeBuild → SST Deploy
|
|
101
|
+
*
|
|
102
|
+
* The pipeline:
|
|
103
|
+
* 1. Detects push to the configured branch via webhook
|
|
104
|
+
* 2. Pulls source code from GitHub
|
|
105
|
+
* 3. CodeBuild installs dependencies, builds the monorepo, and runs `sst deploy`
|
|
106
|
+
* 4. SST deploys the Next.js app to Lambda + CloudFront + S3
|
|
107
|
+
*/
|
|
108
|
+
export declare function createPipeline(config: PipelineConfig): {
|
|
109
|
+
pipeline: {
|
|
110
|
+
name: any;
|
|
111
|
+
arn: any;
|
|
112
|
+
};
|
|
113
|
+
codebuildProject: {
|
|
114
|
+
arn: any;
|
|
115
|
+
name: any;
|
|
116
|
+
};
|
|
117
|
+
connection: {
|
|
118
|
+
arn: any;
|
|
119
|
+
};
|
|
120
|
+
artifactBucket: {
|
|
121
|
+
id: any;
|
|
122
|
+
arn: any;
|
|
123
|
+
bucket: any;
|
|
124
|
+
};
|
|
125
|
+
pipelineName: any;
|
|
126
|
+
pipelineArn: any;
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=Pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pipeline.d.ts","sourceRoot":"","sources":["../../stacks/Pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,WAAW,CAAC,EAAE,sBAAsB,GAAG,uBAAuB,GAAG,sBAAsB,CAAC;IAExF;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc;;;;;;;;;;;;;;;;;;;EA+SpD"}
|