@aws-blocks/core 0.1.2 → 0.1.3

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.
@@ -1,351 +0,0 @@
1
- import type * as cdk from 'aws-cdk-lib';
2
- import type * as codebuild from 'aws-cdk-lib/aws-codebuild';
3
- /**
4
- * Configuration for the pipeline source (GitHub/CodeConnections).
5
- *
6
- * Uses AWS CodeConnections (formerly CodeStar Connections) for OAuth-based
7
- * access to GitHub repositories. No token management required — the
8
- * connection is created once via the AWS Console.
9
- */
10
- export interface PipelineSourceConfig {
11
- /**
12
- * Repository in `owner/repo` format.
13
- *
14
- * @example 'my-org/my-app'
15
- */
16
- readonly repo: string;
17
- /**
18
- * ARN of the AWS CodeConnections connection.
19
- *
20
- * **Important:** This connection requires a one-time OAuth handshake via the
21
- * AWS Console before it can be used. After creating the connection resource
22
- * (via CDK, CLI, or Console), you must complete the OAuth flow in the
23
- * Console under **Developer Tools → Connections** — the connection will be
24
- * in `PENDING` status until authorized.
25
- *
26
- * Steps:
27
- * 1. Create the connection (Console or CLI)
28
- * 2. Navigate to **Developer Tools → Connections** in the AWS Console
29
- * 3. Select the pending connection and click "Update pending connection"
30
- * 4. Authorize the GitHub app and select your repository/organization
31
- * 5. The status changes to `AVAILABLE` — the pipeline can now pull source
32
- *
33
- * @see https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-github.html
34
- *
35
- * @example 'arn:aws:codeconnections:us-east-1:123456789:connection/abc-def'
36
- */
37
- readonly connectionArn: string;
38
- /**
39
- * Whether to trigger the pipeline on push to the branch.
40
- *
41
- * @default true
42
- */
43
- readonly triggerOnPush?: boolean;
44
- /**
45
- * Path-based trigger filters for monorepo support.
46
- *
47
- * When specified, the pipeline only triggers on pushes that modify files
48
- * matching these path patterns. Useful for monorepos where multiple
49
- * pipelines share a single repository.
50
- *
51
- * @example ['packages/backend/**', 'shared/**']
52
- */
53
- readonly triggerFilters?: string[];
54
- }
55
- /**
56
- * Configuration for the synth step (build + CDK synth).
57
- *
58
- * The synth step installs dependencies and runs `cdk synth` to produce
59
- * the CloudFormation template. The pipeline is self-mutating: if the
60
- * synth output changes the pipeline definition, it updates itself first.
61
- */
62
- export interface PipelineSynthConfig {
63
- /**
64
- * Shell commands to run during the synth step.
65
- *
66
- * @default ['npm ci', 'npx cdk synth'] — installs dependencies and synthesizes the CDK app.
67
- * Override if you need Node version upgrades, custom build steps, or a non-standard cdk.json app path.
68
- * If your app requires Node 22+, prepend `'n 22'` to commands or use {@link installCommands}.
69
- */
70
- readonly commands?: string[];
71
- /**
72
- * Commands to run in the CodeBuild install phase (before synth commands).
73
- *
74
- * @default [] — no install commands. The default build image (Amazon Linux 2023 standard:5.0)
75
- * includes Node 22. Set this if you need additional global tools or a different Node version.
76
- *
77
- * @example ['n 20'] — downgrade Node to version 20
78
- */
79
- readonly installCommands?: string[];
80
- /**
81
- * The CodeBuild build image to use for the synth step.
82
- *
83
- * The default image (Amazon Linux 2023 standard:5.0) includes Node 22 and
84
- * Amazon Linux 2023. Override this if you need a different OS or runtime set.
85
- *
86
- * @default codebuild.LinuxBuildImage.AMAZON_LINUX_2023_5
87
- */
88
- readonly buildImage?: codebuild.IBuildImage;
89
- /**
90
- * Environment variables available during synth.
91
- *
92
- * Note: `NODE_OPTIONS` is automatically prepended with `--conditions=cdk`
93
- * (required for ESM conditional exports). Your custom NODE_OPTIONS will be
94
- * appended after this flag.
95
- */
96
- readonly env?: Record<string, string>;
97
- /**
98
- * Primary output directory for the CDK cloud assembly.
99
- *
100
- * Override this for monorepos where `cdk synth` outputs to a
101
- * subdirectory (e.g., `packages/infra/cdk.out`).
102
- *
103
- * @default 'cdk.out'
104
- */
105
- readonly primaryOutputDirectory?: string;
106
- /**
107
- * Whether to enable Docker for the synth step.
108
- *
109
- * Required when your CDK app uses Docker image assets (e.g., Lambda
110
- * container images, ECS task definitions with Dockerfile builds).
111
- *
112
- * @default false
113
- */
114
- readonly dockerEnabled?: boolean;
115
- /**
116
- * CodeBuild compute type for the synth step.
117
- *
118
- * Controls the CPU/memory allocation for the build environment.
119
- * Increase this if you encounter OOM (exit code 137) during synth/bundling.
120
- *
121
- * - `SMALL`: 2 vCPU, 3 GB
122
- * - `MEDIUM`: 4 vCPU, 7 GB
123
- * - `LARGE`: 8 vCPU, 15 GB
124
- *
125
- * @default ComputeType.MEDIUM (7GB RAM, 4 vCPU) — sufficient for most apps with
126
- * Lambda bundling + frontend builds. Use SMALL for trivial apps or LARGE for monorepos.
127
- */
128
- readonly computeType?: codebuild.ComputeType;
129
- }
130
- /**
131
- * Configuration for a deployment stage.
132
- *
133
- * Each stage represents a deployment environment (e.g., beta, prod).
134
- * Stages are deployed in the order they appear in the `stages` array.
135
- */
136
- export interface PipelineStageConfig<TConfig = Record<string, unknown>> {
137
- /**
138
- * Logical name for this stage (e.g., 'beta', 'prod').
139
- * Used as the CDK Stage construct id.
140
- */
141
- readonly name: string;
142
- /**
143
- * Target AWS account and region for this stage.
144
- * When omitted, deploys to the pipeline's own account/region.
145
- */
146
- readonly env?: cdk.Environment;
147
- /**
148
- * Whether to require manual approval before deploying to this stage.
149
- *
150
- * @default false
151
- */
152
- readonly requireApproval?: boolean;
153
- /**
154
- * Optional comment shown in the approval notification.
155
- * Only relevant when `requireApproval` is true.
156
- */
157
- readonly approvalComment?: string;
158
- /**
159
- * Optional baking time after deployment before proceeding.
160
- * Useful for canary validation — gives time for alarms to fire.
161
- *
162
- * Implemented as a CodeBuild `sleep` step (~$0.005/min on
163
- * `BUILD_GENERAL1_SMALL`). An explicit timeout of bakeTime + 10 minutes
164
- * is set on the CodeBuild step to prevent pipeline hangs.
165
- *
166
- * For longer baking periods, use `requireApproval: true` with
167
- * external monitoring/alerting instead.
168
- */
169
- readonly bakeTime?: cdk.Duration;
170
- /**
171
- * User-defined configuration passed through to the `stageFactory`.
172
- *
173
- * Use this for per-stage settings like domain names, feature flags,
174
- * scaling parameters, etc.
175
- *
176
- * @example { domain: 'myapp.com', enableCanary: true }
177
- */
178
- readonly config?: TConfig;
179
- /**
180
- * Environment variables to set on `process.env` when importing the app file for this stage.
181
- *
182
- * These are synthesis-time variables (available during `cdk synth`), not deployment-time.
183
- * Use this for per-stage configuration that your CDK app reads from `process.env`
184
- * (e.g., domain names, feature flags). Only applies when using the `appFile` prop.
185
- *
186
- * @example { DOMAIN: 'myapp.com', ENABLE_CANARY: 'true' }
187
- */
188
- readonly environment?: Record<string, string>;
189
- }
190
- /**
191
- * Configuration for a single branch pipeline.
192
- *
193
- * Each branch entry creates its own independent CodePipeline that triggers
194
- * on pushes to the specified branch and deploys through its own ordered stages.
195
- */
196
- export interface BranchConfig<TConfig = Record<string, unknown>> {
197
- /**
198
- * Git branch that triggers this pipeline.
199
- *
200
- * @example 'main'
201
- */
202
- readonly branch: string;
203
- /**
204
- * Ordered list of deployment stages for this branch's pipeline.
205
- */
206
- readonly stages: Array<PipelineStageConfig<TConfig>>;
207
- /**
208
- * Whether to trigger this branch's pipeline on push.
209
- *
210
- * Overrides the top-level `source.triggerOnPush` for this specific branch.
211
- * Useful when you want most branches to auto-trigger but disable it for
212
- * specific branches (e.g., a release branch that deploys on manual trigger only).
213
- *
214
- * @default inherits from source.triggerOnPush (which defaults to true)
215
- */
216
- readonly triggerOnPush?: boolean;
217
- }
218
- /**
219
- * Props for the {@link Pipeline} L3 construct.
220
- *
221
- * @example Multi-branch configuration
222
- * ```ts
223
- * new Pipeline(stack, 'Pipeline', {
224
- * source: {
225
- * repo: 'my-org/my-app',
226
- * connectionArn: 'arn:aws:codeconnections:us-east-1:123456789:connection/abc',
227
- * },
228
- * branches: [
229
- * {
230
- * branch: 'main',
231
- * stages: [
232
- * { name: 'beta' },
233
- * { name: 'prod', requireApproval: true, config: { domain: 'myapp.com' } },
234
- * ],
235
- * },
236
- * {
237
- * branch: 'develop',
238
- * stages: [
239
- * { name: 'alpha', config: { domain: 'alpha.myapp.com' } },
240
- * ],
241
- * },
242
- * ],
243
- * stageFactory: (scope, stageConfig) => {
244
- * new MyAppStack(scope, 'App', {
245
- * stackName: `my-app-${stageConfig.name}`,
246
- * env: stageConfig.env,
247
- * });
248
- * },
249
- * });
250
- * ```
251
- *
252
- * @example With custom synth and bake time
253
- * ```ts
254
- * new Pipeline(stack, 'Pipeline', {
255
- * source: {
256
- * repo: 'my-org/my-app',
257
- * connectionArn: 'arn:aws:codeconnections:...',
258
- * },
259
- * branches: [
260
- * {
261
- * branch: 'release',
262
- * stages: [
263
- * { name: 'beta' },
264
- * { name: 'prod', requireApproval: true, bakeTime: Duration.minutes(30) },
265
- * ],
266
- * },
267
- * ],
268
- * synth: {
269
- * commands: ['npm ci', 'npm run build', 'npx cdk synth'],
270
- * },
271
- * stageFactory: (scope, stageConfig) => {
272
- * new MyAppStack(scope, 'App', { env: stageConfig.env });
273
- * },
274
- * });
275
- * ```
276
- */
277
- export interface PipelineProps<TConfig = Record<string, unknown>> {
278
- /** Source repository configuration. */
279
- readonly source: PipelineSourceConfig;
280
- /** Synth step configuration. */
281
- readonly synth?: PipelineSynthConfig;
282
- /**
283
- * Branch configurations. Each entry creates a separate CodePipeline.
284
- *
285
- * A single source repository can have multiple branch pipelines, each
286
- * with its own set of deployment stages and configuration.
287
- */
288
- readonly branches: Array<BranchConfig<TConfig>>;
289
- /**
290
- * Factory function that populates a CDK Stage with stacks.
291
- *
292
- * Called once per stage across all branches. The factory receives the Stage
293
- * scope and the full stage configuration object (including `name`, `env`,
294
- * and any user-defined `config`).
295
- *
296
- * May be async when using constructs that require async initialization
297
- * (e.g., `BlocksStack.create()`). When async, use `Pipeline.create()` instead
298
- * of `new Pipeline()` to ensure all stages are fully resolved before synth.
299
- *
300
- * Mutually exclusive with `appFile`. One of `stageFactory` or `appFile` must be provided
301
- * for the sync constructor (`new Pipeline()`). When using `Pipeline.create()`, if neither
302
- * is provided, `appFile` defaults to `'./index.cdk.ts'`.
303
- *
304
- * @param scope - The CDK Stage construct to add stacks to.
305
- * @param stageConfig - The full stage configuration including name, env, and user-defined config.
306
- */
307
- readonly stageFactory?: (scope: cdk.Stage, stageConfig: PipelineStageConfig<TConfig>) => void | Promise<void>;
308
- /**
309
- * Path to the CDK app file to import for each stage.
310
- *
311
- * When provided, the pipeline will dynamically import this file once per stage,
312
- * with the ambient `__PIPELINE_STAGE_SCOPE__` set on globalThis so that
313
- * `BlocksStack.create()` automatically attaches to the correct stage scope.
314
- *
315
- * The path is resolved **relative to the calling file** (not CWD), using
316
- * `Error.stack` to determine the caller's directory. Absolute paths are
317
- * used as-is.
318
- *
319
- * Each stage's `environment` vars are set on `process.env` before the import
320
- * and cleaned up afterward.
321
- *
322
- * Mutually exclusive with `stageFactory`. When using `Pipeline.create()` and
323
- * neither `appFile` nor `stageFactory` is provided, defaults to `'./index.cdk.ts'`
324
- * (resolved relative to the calling file).
325
- *
326
- * **Security:** This path is dynamically imported during CDK synth, executing
327
- * the module's code in the synth process. It MUST originate from a trusted source
328
- * (developer's pipeline definition file). Never wire this from external input
329
- * (environment variables, build args, plugin configs, or user-supplied values).
330
- * A path-containment check enforces that the resolved file stays within the
331
- * project root, and only `.ts`, `.js`, `.mjs`, `.cjs` extensions are accepted.
332
- *
333
- * @default './index.cdk.ts' (when using Pipeline.create() without stageFactory)
334
- * @example './infra/app.ts'
335
- */
336
- readonly appFile?: string;
337
- /**
338
- * Whether the pipeline should self-mutate (update its own definition).
339
- *
340
- * @default true
341
- */
342
- readonly selfMutation?: boolean;
343
- /**
344
- * Cross-account keys for artifact encryption.
345
- * Enable when deploying to accounts different from the pipeline account.
346
- *
347
- * @default false
348
- */
349
- readonly crossAccountKeys?: boolean;
350
- }
351
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pipeline/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,GAAG,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,KAAK,SAAS,MAAM,2BAA2B,CAAC;AAE5D;;;;;;GAMG;AACH,MA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