token-injectable-docker-builder 1.13.4 → 2.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/lib/index.d.ts CHANGED
@@ -1,261 +1,2 @@
1
- import { Duration } from 'aws-cdk-lib';
2
- import { Project } from 'aws-cdk-lib/aws-codebuild';
3
- import { IVpc, ISecurityGroup, SubnetSelection } from 'aws-cdk-lib/aws-ec2';
4
- import { Repository } from 'aws-cdk-lib/aws-ecr';
5
- import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
6
- import { Key } from 'aws-cdk-lib/aws-kms';
7
- import { DockerImageCode } from 'aws-cdk-lib/aws-lambda';
8
- import { ILogGroup } from 'aws-cdk-lib/aws-logs';
9
- import { Construct } from 'constructs';
10
- /**
11
- * Options for creating a `TokenInjectableDockerBuilderProvider`.
12
- */
13
- export interface TokenInjectableDockerBuilderProviderProps {
14
- /**
15
- * How often the provider polls for build completion.
16
- *
17
- * @default Duration.seconds(30)
18
- */
19
- readonly queryInterval?: Duration;
20
- }
21
- /**
22
- * Shared provider for `TokenInjectableDockerBuilder` instances.
23
- *
24
- * Creates the onEvent and isComplete Lambda functions once per stack.
25
- * Each builder instance registers its CodeBuild project ARN so the
26
- * shared Lambdas have permission to start builds and read logs.
27
- */
28
- export declare class TokenInjectableDockerBuilderProvider extends Construct {
29
- /**
30
- * Get or create the singleton provider for this stack.
31
- * All `TokenInjectableDockerBuilder` instances in the same stack
32
- * share a single pair of Lambda functions.
33
- */
34
- static getOrCreate(scope: Construct, props?: TokenInjectableDockerBuilderProviderProps): TokenInjectableDockerBuilderProvider;
35
- /** The service token used by CustomResource instances. */
36
- readonly serviceToken: string;
37
- private readonly onEventHandlerFunction;
38
- private readonly isCompleteHandlerFunction;
39
- private constructor();
40
- /**
41
- * Grant the shared Lambdas permission to start builds for a specific
42
- * CodeBuild project and pull/push to its ECR repository.
43
- */
44
- registerProject(project: Project, ecrRepo: Repository, encryptionKey?: Key): void;
45
- }
46
- /**
47
- * Properties for the `TokenInjectableDockerBuilder` construct.
48
- */
49
- export interface TokenInjectableDockerBuilderProps {
50
- /**
51
- * The path to the directory containing the Dockerfile or source code.
52
- */
53
- readonly path: string;
54
- /**
55
- * Build arguments to pass to the Docker build process.
56
- * These are transformed into `--build-arg KEY=VALUE` flags.
57
- * @example
58
- * {
59
- * TOKEN: 'my-secret-token',
60
- * ENV: 'production'
61
- * }
62
- */
63
- readonly buildArgs?: {
64
- [key: string]: string;
65
- };
66
- /**
67
- * The ARN of the AWS Secrets Manager secret containing Docker login credentials.
68
- * This secret should store a JSON object with the following structure:
69
- * ```json
70
- * {
71
- * "username": "my-docker-username",
72
- * "password": "my-docker-password"
73
- * }
74
- * ```
75
- * If not provided (or not needed), the construct will skip Docker Hub login.
76
- *
77
- * **Note**: The secret must be in the same region as the stack.
78
- *
79
- * @example 'arn:aws:secretsmanager:us-east-1:123456789012:secret:DockerLoginSecret'
80
- */
81
- readonly dockerLoginSecretArn?: string;
82
- /**
83
- * The VPC in which the CodeBuild project will be deployed.
84
- * If provided, the CodeBuild project will be launched within the specified VPC.
85
- *
86
- * @default - No VPC is attached, and the CodeBuild project will use public internet.
87
- */
88
- readonly vpc?: IVpc;
89
- /**
90
- * The security groups to attach to the CodeBuild project.
91
- * These define the network access rules for the CodeBuild project.
92
- *
93
- * @default - No security groups are attached.
94
- */
95
- readonly securityGroups?: ISecurityGroup[];
96
- /**
97
- * The subnet selection to specify which subnets to use within the VPC.
98
- * Allows the user to select private, public, or isolated subnets.
99
- *
100
- * @default - All subnets in the VPC are used.
101
- */
102
- readonly subnetSelection?: SubnetSelection;
103
- /**
104
- * Custom commands to run during the install phase of CodeBuild.
105
- *
106
- * **Example**:
107
- * ```ts
108
- * installCommands: [
109
- * 'echo "Updating package lists..."',
110
- * 'apt-get update -y',
111
- * 'echo "Installing required packages..."',
112
- * 'apt-get install -y curl dnsutils',
113
- * ],
114
- * ```
115
- * @default - No additional install commands.
116
- */
117
- readonly installCommands?: string[];
118
- /**
119
- * Custom commands to run during the pre_build phase of CodeBuild.
120
- *
121
- * **Example**:
122
- * ```ts
123
- * preBuildCommands: [
124
- * 'echo "Fetching configuration from private API..."',
125
- * 'curl -o config.json https://api.example.com/config',
126
- * ],
127
- * ```
128
- * @default - No additional pre-build commands.
129
- */
130
- readonly preBuildCommands?: string[];
131
- /**
132
- * Whether to enable KMS encryption for the ECR repository.
133
- * If `true`, a KMS key will be created for encrypting ECR images.
134
- * If `false`, the repository will use AES-256 encryption.
135
- *
136
- * @default - false
137
- */
138
- readonly kmsEncryption?: boolean;
139
- /**
140
- * The query interval for checking if the CodeBuild project has completed.
141
- * This determines how frequently the custom resource polls for build completion.
142
- *
143
- * @default - Duration.seconds(30)
144
- */
145
- readonly completenessQueryInterval?: Duration;
146
- /**
147
- * A list of file paths in the Docker directory to exclude from build.
148
- * Will use paths in .dockerignore file if present.
149
- *
150
- * @default - No file path exclusions
151
- */
152
- readonly exclude?: string[];
153
- /**
154
- * The name of the Dockerfile to use for the build.
155
- * Passed as `--file` to `docker build`.
156
- *
157
- * @example 'Dockerfile.production'
158
- * @default 'Dockerfile'
159
- */
160
- readonly file?: string;
161
- /**
162
- * When `true`, disables Docker layer caching. Every build runs from scratch.
163
- * Use for debugging, corrupted cache, or major dependency changes.
164
- *
165
- * @default false
166
- */
167
- readonly cacheDisabled?: boolean;
168
- /**
169
- * CloudWatch log group for CodeBuild build logs.
170
- * When provided with a RETAIN removal policy, build logs survive rollbacks
171
- * and stack deletion for debugging.
172
- *
173
- * @default - CodeBuild default logging (logs are deleted on rollback)
174
- */
175
- readonly buildLogGroup?: ILogGroup;
176
- /**
177
- * Target platform for the Docker image.
178
- *
179
- * When set to `'linux/arm64'`, the construct uses a native ARM/Graviton
180
- * CodeBuild instance for fast builds without emulation.
181
- *
182
- * @default 'linux/amd64'
183
- */
184
- readonly platform?: 'linux/amd64' | 'linux/arm64';
185
- /**
186
- * Shared provider for the custom resource Lambdas.
187
- * Use `TokenInjectableDockerBuilderProvider.getOrCreate(this)` to create
188
- * a singleton that is shared across all builders in the same stack.
189
- *
190
- * When omitted, each builder creates its own Lambdas (original behavior).
191
- *
192
- * @default - A new provider is created per builder instance
193
- */
194
- readonly provider?: TokenInjectableDockerBuilderProvider;
195
- /**
196
- * ECR pull-through cache repository prefixes to grant pull access to.
197
- * Use when your Dockerfile references base images from ECR pull-through
198
- * cache (e.g. docker-hub/library/node:20-slim, ghcr/org/image:tag).
199
- * The CodeBuild role will be granted ecr:BatchGetImage, ecr:GetDownloadUrlForLayer,
200
- * and ecr:BatchCheckLayerAvailability on repositories matching each prefix.
201
- *
202
- * @example ['docker-hub', 'ghcr']
203
- * @default - No pull-through cache access
204
- */
205
- readonly ecrPullThroughCachePrefixes?: string[];
206
- /**
207
- * Maximum number of tagged images to retain in the ECR repository.
208
- *
209
- * **WARNING:** Lambda functions pin images by digest internally even when
210
- * referenced by tag. Setting this can delete images that Lambda functions
211
- * (and ECS tasks) are still pinned to, breaking the next configuration
212
- * update with "Image ID cannot be found".
213
- *
214
- * Leave undefined (the default) for production use. Untagged images are
215
- * always cleaned up after 30 days regardless of this setting.
216
- *
217
- * @default undefined - no count-based expiration; only untagged-after-30-days
218
- */
219
- readonly maxImageCount?: number;
220
- /**
221
- * When `true`, creates a CloudWatch log group outside of CloudFormation
222
- * (`/docker-builder/<projectName>`) and directs CodeBuild output there.
223
- * Because the log group is managed imperatively (not by CloudFormation),
224
- * it survives stack rollbacks and preserves full build logs for debugging.
225
- * A 7-day retention policy is applied so old logs auto-expire.
226
- *
227
- * Set to `false` after debugging to delete the log group and clean up.
228
- *
229
- * @default false
230
- */
231
- readonly retainBuildLogs?: boolean;
232
- }
233
- /**
234
- * A CDK construct to build and push Docker images to an ECR repository using
235
- * CodeBuild and Lambda custom resources, **then** retrieve the final image tag
236
- * so that ECS/Lambda references use the exact digest.
237
- */
238
- export declare class TokenInjectableDockerBuilder extends Construct {
239
- /**
240
- * The ECR repository that stores the resulting Docker image.
241
- */
242
- private readonly ecrRepository;
243
- /**
244
- * An ECS-compatible container image referencing the tag
245
- * of the built Docker image.
246
- */
247
- readonly containerImage: ContainerImage;
248
- /**
249
- * A Lambda-compatible DockerImageCode referencing the tag
250
- * of the built Docker image.
251
- */
252
- readonly dockerImageCode: DockerImageCode;
253
- /**
254
- * Creates a new `TokenInjectableDockerBuilder`.
255
- *
256
- * @param scope The scope in which to define this construct.
257
- * @param id The scoped construct ID.
258
- * @param props Configuration for building and pushing the Docker image.
259
- */
260
- constructor(scope: Construct, id: string, props: TokenInjectableDockerBuilderProps);
261
- }
1
+ export { TokenInjectableDockerBuilder, TokenInjectableDockerBuilderProps, } from './builder';
2
+ export { TokenInjectableDockerBuilderProvider, TokenInjectableDockerBuilderProviderProps, } from './provider';