UNPKG

43.4 kBTypeScriptView Raw
1import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
2import * as notifications from '@aws-cdk/aws-codestarnotifications';
3import * as ec2 from '@aws-cdk/aws-ec2';
4import * as ecr from '@aws-cdk/aws-ecr';
5import { DockerImageAssetProps } from '@aws-cdk/aws-ecr-assets';
6import * as events from '@aws-cdk/aws-events';
7import * as iam from '@aws-cdk/aws-iam';
8import * as kms from '@aws-cdk/aws-kms';
9import * as s3 from '@aws-cdk/aws-s3';
10import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
11import { Duration, IResource, Resource } from '@aws-cdk/core';
12import { Construct } from 'constructs';
13import { IArtifacts } from './artifacts';
14import { BuildSpec } from './build-spec';
15import { Cache } from './cache';
16import { CfnProject } from './codebuild.generated';
17import { IFileSystemLocation } from './file-location';
18import { LoggingOptions } from './project-logs';
19import { ISource } from './source';
20import { Construct as CoreConstruct } from '@aws-cdk/core';
21/**
22 * The type returned from {@link IProject#enableBatchBuilds}.
23 */
24export interface BatchBuildConfig {
25 /** The IAM batch service Role of this Project. */
26 readonly role: iam.IRole;
27}
28/**
29 * Location of a PEM certificate on S3
30 */
31export interface BuildEnvironmentCertificate {
32 /**
33 * The bucket where the certificate is
34 */
35 readonly bucket: s3.IBucket;
36 /**
37 * The full path and name of the key file
38 */
39 readonly objectKey: string;
40}
41/**
42 * Additional options to pass to the notification rule.
43 */
44export interface ProjectNotifyOnOptions extends notifications.NotificationRuleOptions {
45 /**
46 * A list of event types associated with this notification rule for CodeBuild Project.
47 * For a complete list of event types and IDs, see Notification concepts in the Developer Tools Console User Guide.
48 * @see https://docs.aws.amazon.com/dtconsole/latest/userguide/concepts.html#concepts-api
49 */
50 readonly events: ProjectNotificationEvents[];
51}
52export interface IProject extends IResource, iam.IGrantable, ec2.IConnectable, notifications.INotificationRuleSource {
53 /**
54 * The ARN of this Project.
55 * @attribute
56 */
57 readonly projectArn: string;
58 /**
59 * The human-visible name of this Project.
60 * @attribute
61 */
62 readonly projectName: string;
63 /** The IAM service Role of this Project. Undefined for imported Projects. */
64 readonly role?: iam.IRole;
65 /**
66 * Enable batch builds.
67 *
68 * Returns an object contining the batch service role if batch builds
69 * could be enabled.
70 */
71 enableBatchBuilds(): BatchBuildConfig | undefined;
72 addToRolePolicy(policyStatement: iam.PolicyStatement): void;
73 /**
74 * Defines a CloudWatch event rule triggered when something happens with this project.
75 *
76 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
77 */
78 onEvent(id: string, options?: events.OnEventOptions): events.Rule;
79 /**
80 * Defines a CloudWatch event rule triggered when the build project state
81 * changes. You can filter specific build status events using an event
82 * pattern filter on the `build-status` detail field:
83 *
84 * const rule = project.onStateChange('OnBuildStarted', { target });
85 * rule.addEventPattern({
86 * detail: {
87 * 'build-status': [
88 * "IN_PROGRESS",
89 * "SUCCEEDED",
90 * "FAILED",
91 * "STOPPED"
92 * ]
93 * }
94 * });
95 *
96 * You can also use the methods `onBuildFailed` and `onBuildSucceeded` to define rules for
97 * these specific state changes.
98 *
99 * To access fields from the event in the event target input,
100 * use the static fields on the `StateChangeEvent` class.
101 *
102 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
103 */
104 onStateChange(id: string, options?: events.OnEventOptions): events.Rule;
105 /**
106 * Defines a CloudWatch event rule that triggers upon phase change of this
107 * build project.
108 *
109 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
110 */
111 onPhaseChange(id: string, options?: events.OnEventOptions): events.Rule;
112 /**
113 * Defines an event rule which triggers when a build starts.
114 */
115 onBuildStarted(id: string, options?: events.OnEventOptions): events.Rule;
116 /**
117 * Defines an event rule which triggers when a build fails.
118 */
119 onBuildFailed(id: string, options?: events.OnEventOptions): events.Rule;
120 /**
121 * Defines an event rule which triggers when a build completes successfully.
122 */
123 onBuildSucceeded(id: string, options?: events.OnEventOptions): events.Rule;
124 /**
125 * @returns a CloudWatch metric associated with this build project.
126 * @param metricName The name of the metric
127 * @param props Customization properties
128 */
129 metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
130 /**
131 * Measures the number of builds triggered.
132 *
133 * Units: Count
134 *
135 * Valid CloudWatch statistics: Sum
136 *
137 * @default sum over 5 minutes
138 */
139 metricBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
140 /**
141 * Measures the duration of all builds over time.
142 *
143 * Units: Seconds
144 *
145 * Valid CloudWatch statistics: Average (recommended), Maximum, Minimum
146 *
147 * @default average over 5 minutes
148 */
149 metricDuration(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
150 /**
151 * Measures the number of successful builds.
152 *
153 * Units: Count
154 *
155 * Valid CloudWatch statistics: Sum
156 *
157 * @default sum over 5 minutes
158 */
159 metricSucceededBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
160 /**
161 * Measures the number of builds that failed because of client error or
162 * because of a timeout.
163 *
164 * Units: Count
165 *
166 * Valid CloudWatch statistics: Sum
167 *
168 * @default sum over 5 minutes
169 */
170 metricFailedBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
171 /**
172 * Defines a CodeStar Notification rule triggered when the project
173 * events emitted by you specified, it very similar to `onEvent` API.
174 *
175 * You can also use the methods `notifyOnBuildSucceeded` and
176 * `notifyOnBuildFailed` to define rules for these specific event emitted.
177 *
178 * @param id The logical identifier of the CodeStar Notifications rule that will be created
179 * @param target The target to register for the CodeStar Notifications destination.
180 * @param options Customization options for CodeStar Notifications rule
181 * @returns CodeStar Notifications rule associated with this build project.
182 */
183 notifyOn(id: string, target: notifications.INotificationRuleTarget, options: ProjectNotifyOnOptions): notifications.INotificationRule;
184 /**
185 * Defines a CodeStar notification rule which triggers when a build completes successfully.
186 */
187 notifyOnBuildSucceeded(id: string, target: notifications.INotificationRuleTarget, options?: notifications.NotificationRuleOptions): notifications.INotificationRule;
188 /**
189 * Defines a CodeStar notification rule which triggers when a build fails.
190 */
191 notifyOnBuildFailed(id: string, target: notifications.INotificationRuleTarget, options?: notifications.NotificationRuleOptions): notifications.INotificationRule;
192}
193/**
194 * Represents a reference to a CodeBuild Project.
195 *
196 * If you're managing the Project alongside the rest of your CDK resources,
197 * use the {@link Project} class.
198 *
199 * If you want to reference an already existing Project
200 * (or one defined in a different CDK Stack),
201 * use the {@link import} method.
202 */
203declare abstract class ProjectBase extends Resource implements IProject {
204 abstract readonly grantPrincipal: iam.IPrincipal;
205 /** The ARN of this Project. */
206 abstract readonly projectArn: string;
207 /** The human-visible name of this Project. */
208 abstract readonly projectName: string;
209 /** The IAM service Role of this Project. */
210 abstract readonly role?: iam.IRole;
211 /**
212 * Actual connections object for this Project.
213 * May be unset, in which case this Project is not configured to use a VPC.
214 * @internal
215 */
216 protected _connections: ec2.Connections | undefined;
217 /**
218 * Access the Connections object.
219 * Will fail if this Project does not have a VPC set.
220 */
221 get connections(): ec2.Connections;
222 enableBatchBuilds(): BatchBuildConfig | undefined;
223 /**
224 * Add a permission only if there's a policy attached.
225 * @param statement The permissions statement to add
226 */
227 addToRolePolicy(statement: iam.PolicyStatement): void;
228 /**
229 * Defines a CloudWatch event rule triggered when something happens with this project.
230 *
231 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
232 */
233 onEvent(id: string, options?: events.OnEventOptions): events.Rule;
234 /**
235 * Defines a CloudWatch event rule triggered when the build project state
236 * changes. You can filter specific build status events using an event
237 * pattern filter on the `build-status` detail field:
238 *
239 * const rule = project.onStateChange('OnBuildStarted', { target });
240 * rule.addEventPattern({
241 * detail: {
242 * 'build-status': [
243 * "IN_PROGRESS",
244 * "SUCCEEDED",
245 * "FAILED",
246 * "STOPPED"
247 * ]
248 * }
249 * });
250 *
251 * You can also use the methods `onBuildFailed` and `onBuildSucceeded` to define rules for
252 * these specific state changes.
253 *
254 * To access fields from the event in the event target input,
255 * use the static fields on the `StateChangeEvent` class.
256 *
257 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
258 */
259 onStateChange(id: string, options?: events.OnEventOptions): events.Rule;
260 /**
261 * Defines a CloudWatch event rule that triggers upon phase change of this
262 * build project.
263 *
264 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html
265 */
266 onPhaseChange(id: string, options?: events.OnEventOptions): events.Rule;
267 /**
268 * Defines an event rule which triggers when a build starts.
269 *
270 * To access fields from the event in the event target input,
271 * use the static fields on the `StateChangeEvent` class.
272 */
273 onBuildStarted(id: string, options?: events.OnEventOptions): events.Rule;
274 /**
275 * Defines an event rule which triggers when a build fails.
276 *
277 * To access fields from the event in the event target input,
278 * use the static fields on the `StateChangeEvent` class.
279 */
280 onBuildFailed(id: string, options?: events.OnEventOptions): events.Rule;
281 /**
282 * Defines an event rule which triggers when a build completes successfully.
283 *
284 * To access fields from the event in the event target input,
285 * use the static fields on the `StateChangeEvent` class.
286 */
287 onBuildSucceeded(id: string, options?: events.OnEventOptions): events.Rule;
288 /**
289 * @returns a CloudWatch metric associated with this build project.
290 * @param metricName The name of the metric
291 * @param props Customization properties
292 */
293 metric(metricName: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric;
294 /**
295 * Measures the number of builds triggered.
296 *
297 * Units: Count
298 *
299 * Valid CloudWatch statistics: Sum
300 *
301 * @default sum over 5 minutes
302 */
303 metricBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
304 /**
305 * Measures the duration of all builds over time.
306 *
307 * Units: Seconds
308 *
309 * Valid CloudWatch statistics: Average (recommended), Maximum, Minimum
310 *
311 * @default average over 5 minutes
312 */
313 metricDuration(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
314 /**
315 * Measures the number of successful builds.
316 *
317 * Units: Count
318 *
319 * Valid CloudWatch statistics: Sum
320 *
321 * @default sum over 5 minutes
322 */
323 metricSucceededBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
324 /**
325 * Measures the number of builds that failed because of client error or
326 * because of a timeout.
327 *
328 * Units: Count
329 *
330 * Valid CloudWatch statistics: Sum
331 *
332 * @default sum over 5 minutes
333 */
334 metricFailedBuilds(props?: cloudwatch.MetricOptions): cloudwatch.Metric;
335 notifyOn(id: string, target: notifications.INotificationRuleTarget, options: ProjectNotifyOnOptions): notifications.INotificationRule;
336 notifyOnBuildSucceeded(id: string, target: notifications.INotificationRuleTarget, options?: notifications.NotificationRuleOptions): notifications.INotificationRule;
337 notifyOnBuildFailed(id: string, target: notifications.INotificationRuleTarget, options?: notifications.NotificationRuleOptions): notifications.INotificationRule;
338 bindAsNotificationRuleSource(_scope: Construct): notifications.NotificationRuleSourceConfig;
339 private cannedMetric;
340}
341export interface CommonProjectProps {
342 /**
343 * A description of the project. Use the description to identify the purpose
344 * of the project.
345 *
346 * @default - No description.
347 */
348 readonly description?: string;
349 /**
350 * Filename or contents of buildspec in JSON format.
351 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-example
352 *
353 * @default - Empty buildspec.
354 */
355 readonly buildSpec?: BuildSpec;
356 /**
357 * Service Role to assume while running the build.
358 *
359 * @default - A role will be created.
360 */
361 readonly role?: iam.IRole;
362 /**
363 * Encryption key to use to read and write artifacts.
364 *
365 * @default - The AWS-managed CMK for Amazon Simple Storage Service (Amazon S3) is used.
366 */
367 readonly encryptionKey?: kms.IKey;
368 /**
369 * Caching strategy to use.
370 *
371 * @default Cache.none
372 */
373 readonly cache?: Cache;
374 /**
375 * Build environment to use for the build.
376 *
377 * @default BuildEnvironment.LinuxBuildImage.STANDARD_1_0
378 */
379 readonly environment?: BuildEnvironment;
380 /**
381 * Indicates whether AWS CodeBuild generates a publicly accessible URL for
382 * your project's build badge. For more information, see Build Badges Sample
383 * in the AWS CodeBuild User Guide.
384 *
385 * @default false
386 */
387 readonly badge?: boolean;
388 /**
389 * The number of minutes after which AWS CodeBuild stops the build if it's
390 * not complete. For valid values, see the timeoutInMinutes field in the AWS
391 * CodeBuild User Guide.
392 *
393 * @default Duration.hours(1)
394 */
395 readonly timeout?: Duration;
396 /**
397 * Additional environment variables to add to the build environment.
398 *
399 * @default - No additional environment variables are specified.
400 */
401 readonly environmentVariables?: {
402 [name: string]: BuildEnvironmentVariable;
403 };
404 /**
405 * Whether to check for the presence of any secrets in the environment variables of the default type, BuildEnvironmentVariableType.PLAINTEXT.
406 * Since using a secret for the value of that kind of variable would result in it being displayed in plain text in the AWS Console,
407 * the construct will throw an exception if it detects a secret was passed there.
408 * Pass this property as false if you want to skip this validation,
409 * and keep using a secret in a plain text environment variable.
410 *
411 * @default true
412 */
413 readonly checkSecretsInPlainTextEnvVariables?: boolean;
414 /**
415 * The physical, human-readable name of the CodeBuild Project.
416 *
417 * @default - Name is automatically generated.
418 */
419 readonly projectName?: string;
420 /**
421 * VPC network to place codebuild network interfaces
422 *
423 * Specify this if the codebuild project needs to access resources in a VPC.
424 *
425 * @default - No VPC is specified.
426 */
427 readonly vpc?: ec2.IVpc;
428 /**
429 * Where to place the network interfaces within the VPC.
430 *
431 * Only used if 'vpc' is supplied.
432 *
433 * @default - All private subnets.
434 */
435 readonly subnetSelection?: ec2.SubnetSelection;
436 /**
437 * What security group to associate with the codebuild project's network interfaces.
438 * If no security group is identified, one will be created automatically.
439 *
440 * Only used if 'vpc' is supplied.
441 *
442 * @default - Security group will be automatically created.
443 *
444 */
445 readonly securityGroups?: ec2.ISecurityGroup[];
446 /**
447 * Whether to allow the CodeBuild to send all network traffic
448 *
449 * If set to false, you must individually add traffic rules to allow the
450 * CodeBuild project to connect to network targets.
451 *
452 * Only used if 'vpc' is supplied.
453 *
454 * @default true
455 */
456 readonly allowAllOutbound?: boolean;
457 /**
458 * An ProjectFileSystemLocation objects for a CodeBuild build project.
459 *
460 * A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint,
461 * and type of a file system created using Amazon Elastic File System.
462 *
463 * @default - no file system locations
464 */
465 readonly fileSystemLocations?: IFileSystemLocation[];
466 /**
467 * Add permissions to this project's role to create and use test report groups with name starting with the name of this project.
468 *
469 * That is the standard report group that gets created when a simple name
470 * (in contrast to an ARN)
471 * is used in the 'reports' section of the buildspec of this project.
472 * This is usually harmless, but you can turn these off if you don't plan on using test
473 * reports in this project.
474 *
475 * @default true
476 *
477 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/test-report-group-naming.html
478 */
479 readonly grantReportGroupPermissions?: boolean;
480 /**
481 * Information about logs for the build project. A project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.
482 *
483 * @default - no log configuration is set
484 */
485 readonly logging?: LoggingOptions;
486 /**
487 * The number of minutes after which AWS CodeBuild stops the build if it's
488 * still in queue. For valid values, see the timeoutInMinutes field in the AWS
489 * CodeBuild User Guide.
490 *
491 * @default - no queue timeout is set
492 */
493 readonly queuedTimeout?: Duration;
494 /**
495 * Maximum number of concurrent builds. Minimum value is 1 and maximum is account build limit.
496 *
497 * @default - no explicit limit is set
498 */
499 readonly concurrentBuildLimit?: number;
500}
501export interface ProjectProps extends CommonProjectProps {
502 /**
503 * The source of the build.
504 * *Note*: if {@link NoSource} is given as the source,
505 * then you need to provide an explicit `buildSpec`.
506 *
507 * @default - NoSource
508 */
509 readonly source?: ISource;
510 /**
511 * Defines where build artifacts will be stored.
512 * Could be: PipelineBuildArtifacts, NoArtifacts and S3Artifacts.
513 *
514 * @default NoArtifacts
515 */
516 readonly artifacts?: IArtifacts;
517 /**
518 * The secondary sources for the Project.
519 * Can be also added after the Project has been created by using the {@link Project#addSecondarySource} method.
520 *
521 * @default - No secondary sources.
522 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
523 */
524 readonly secondarySources?: ISource[];
525 /**
526 * The secondary artifacts for the Project.
527 * Can also be added after the Project has been created by using the {@link Project#addSecondaryArtifact} method.
528 *
529 * @default - No secondary artifacts.
530 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
531 */
532 readonly secondaryArtifacts?: IArtifacts[];
533}
534/**
535 * The extra options passed to the {@link IProject.bindToCodePipeline} method.
536 */
537export interface BindToCodePipelineOptions {
538 /**
539 * The artifact bucket that will be used by the action that invokes this project.
540 */
541 readonly artifactBucket: s3.IBucket;
542}
543/**
544 * A representation of a CodeBuild Project.
545 */
546export declare class Project extends ProjectBase {
547 static fromProjectArn(scope: Construct, id: string, projectArn: string): IProject;
548 /**
549 * Import a Project defined either outside the CDK,
550 * or in a different CDK Stack
551 * (and exported using the {@link export} method).
552 *
553 * @note if you're importing a CodeBuild Project for use
554 * in a CodePipeline, make sure the existing Project
555 * has permissions to access the S3 Bucket of that Pipeline -
556 * otherwise, builds in that Pipeline will always fail.
557 *
558 * @param scope the parent Construct for this Construct
559 * @param id the logical name of this Construct
560 * @param projectName the name of the project to import
561 * @returns a reference to the existing Project
562 */
563 static fromProjectName(scope: Construct, id: string, projectName: string): IProject;
564 /**
565 * Convert the environment variables map of string to {@link BuildEnvironmentVariable},
566 * which is the customer-facing type, to a list of {@link CfnProject.EnvironmentVariableProperty},
567 * which is the representation of environment variables in CloudFormation.
568 *
569 * @param environmentVariables the map of string to environment variables
570 * @param validateNoPlainTextSecrets whether to throw an exception
571 * if any of the plain text environment variables contain secrets, defaults to 'false'
572 * @returns an array of {@link CfnProject.EnvironmentVariableProperty} instances
573 */
574 static serializeEnvVariables(environmentVariables: {
575 [name: string]: BuildEnvironmentVariable;
576 }, validateNoPlainTextSecrets?: boolean, principal?: iam.IGrantable): CfnProject.EnvironmentVariableProperty[];
577 readonly grantPrincipal: iam.IPrincipal;
578 /**
579 * The IAM role for this project.
580 */
581 readonly role?: iam.IRole;
582 /**
583 * The ARN of the project.
584 */
585 readonly projectArn: string;
586 /**
587 * The name of the project.
588 */
589 readonly projectName: string;
590 private readonly source;
591 private readonly buildImage;
592 private readonly _secondarySources;
593 private readonly _secondarySourceVersions;
594 private readonly _secondaryArtifacts;
595 private _encryptionKey?;
596 private readonly _fileSystemLocations;
597 private _batchServiceRole?;
598 constructor(scope: Construct, id: string, props: ProjectProps);
599 enableBatchBuilds(): BatchBuildConfig | undefined;
600 /**
601 * Adds a secondary source to the Project.
602 *
603 * @param secondarySource the source to add as a secondary source
604 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
605 */
606 addSecondarySource(secondarySource: ISource): void;
607 /**
608 * Adds a fileSystemLocation to the Project.
609 *
610 * @param fileSystemLocation the fileSystemLocation to add
611 */
612 addFileSystemLocation(fileSystemLocation: IFileSystemLocation): void;
613 /**
614 * Adds a secondary artifact to the Project.
615 *
616 * @param secondaryArtifact the artifact to add as a secondary artifact
617 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
618 */
619 addSecondaryArtifact(secondaryArtifact: IArtifacts): void;
620 /**
621 * A callback invoked when the given project is added to a CodePipeline.
622 *
623 * @param _scope the construct the binding is taking place in
624 * @param options additional options for the binding
625 */
626 bindToCodePipeline(_scope: CoreConstruct, options: BindToCodePipelineOptions): void;
627 /**
628 * @override
629 */
630 protected validate(): string[];
631 private set encryptionKey(value);
632 private createLoggingPermission;
633 private renderEnvironment;
634 private renderFileSystemLocations;
635 private renderSecondarySources;
636 private renderSecondarySourceVersions;
637 private renderSecondaryArtifacts;
638 /**
639 * If configured, set up the VPC-related properties
640 *
641 * Returns the VpcConfig that should be added to the
642 * codebuild creation properties.
643 */
644 private configureVpc;
645 private renderLoggingConfiguration;
646 private addVpcRequiredPermissions;
647 private validateCodePipelineSettings;
648}
649/**
650 * Build machine compute type.
651 */
652export declare enum ComputeType {
653 SMALL = "BUILD_GENERAL1_SMALL",
654 MEDIUM = "BUILD_GENERAL1_MEDIUM",
655 LARGE = "BUILD_GENERAL1_LARGE",
656 X2_LARGE = "BUILD_GENERAL1_2XLARGE"
657}
658/**
659 * The type of principal CodeBuild will use to pull your build Docker image.
660 */
661export declare enum ImagePullPrincipalType {
662 /**
663 * CODEBUILD specifies that CodeBuild uses its own identity when pulling the image.
664 * This means the resource policy of the ECR repository that hosts the image will be modified to trust
665 * CodeBuild's service principal.
666 * This is the required principal type when using CodeBuild's pre-defined images.
667 */
668 CODEBUILD = "CODEBUILD",
669 /**
670 * SERVICE_ROLE specifies that AWS CodeBuild uses the project's role when pulling the image.
671 * The role will be granted pull permissions on the ECR repository hosting the image.
672 */
673 SERVICE_ROLE = "SERVICE_ROLE"
674}
675export interface BuildEnvironment {
676 /**
677 * The image used for the builds.
678 *
679 * @default LinuxBuildImage.STANDARD_1_0
680 */
681 readonly buildImage?: IBuildImage;
682 /**
683 * The type of compute to use for this build.
684 * See the {@link ComputeType} enum for the possible values.
685 *
686 * @default taken from {@link #buildImage#defaultComputeType}
687 */
688 readonly computeType?: ComputeType;
689 /**
690 * Indicates how the project builds Docker images. Specify true to enable
691 * running the Docker daemon inside a Docker container. This value must be
692 * set to true only if this build project will be used to build Docker
693 * images, and the specified build environment image is not one provided by
694 * AWS CodeBuild with Docker support. Otherwise, all associated builds that
695 * attempt to interact with the Docker daemon will fail.
696 *
697 * @default false
698 */
699 readonly privileged?: boolean;
700 /**
701 * The location of the PEM-encoded certificate for the build project
702 *
703 * @default - No external certificate is added to the project
704 */
705 readonly certificate?: BuildEnvironmentCertificate;
706 /**
707 * The environment variables that your builds can use.
708 */
709 readonly environmentVariables?: {
710 [name: string]: BuildEnvironmentVariable;
711 };
712}
713/**
714 * Represents a Docker image used for the CodeBuild Project builds.
715 * Use the concrete subclasses, either:
716 * {@link LinuxBuildImage} or {@link WindowsBuildImage}.
717 */
718export interface IBuildImage {
719 /**
720 * The type of build environment.
721 */
722 readonly type: string;
723 /**
724 * The Docker image identifier that the build environment uses.
725 *
726 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
727 */
728 readonly imageId: string;
729 /**
730 * The default {@link ComputeType} to use with this image,
731 * if one was not specified in {@link BuildEnvironment#computeType} explicitly.
732 */
733 readonly defaultComputeType: ComputeType;
734 /**
735 * The type of principal that CodeBuild will use to pull this build Docker image.
736 *
737 * @default ImagePullPrincipalType.SERVICE_ROLE
738 */
739 readonly imagePullPrincipalType?: ImagePullPrincipalType;
740 /**
741 * The secretsManagerCredentials for access to a private registry.
742 *
743 * @default no credentials will be used
744 */
745 readonly secretsManagerCredentials?: secretsmanager.ISecret;
746 /**
747 * An optional ECR repository that the image is hosted in.
748 *
749 * @default no repository
750 */
751 readonly repository?: ecr.IRepository;
752 /**
753 * Allows the image a chance to validate whether the passed configuration is correct.
754 *
755 * @param buildEnvironment the current build environment
756 */
757 validate(buildEnvironment: BuildEnvironment): string[];
758 /**
759 * Make a buildspec to run the indicated script
760 */
761 runScriptBuildspec(entrypoint: string): BuildSpec;
762}
763/** Optional arguments to {@link IBuildImage.binder} - currently empty. */
764export interface BuildImageBindOptions {
765}
766/** The return type from {@link IBuildImage.binder} - currently empty. */
767export interface BuildImageConfig {
768}
769/** A variant of {@link IBuildImage} that allows binding to the project. */
770export interface IBindableBuildImage extends IBuildImage {
771 /** Function that allows the build image access to the construct tree. */
772 bind(scope: CoreConstruct, project: IProject, options: BuildImageBindOptions): BuildImageConfig;
773}
774/**
775 * The options when creating a CodeBuild Docker build image
776 * using {@link LinuxBuildImage.fromDockerRegistry}
777 * or {@link WindowsBuildImage.fromDockerRegistry}.
778 */
779export interface DockerImageOptions {
780 /**
781 * The credentials, stored in Secrets Manager,
782 * used for accessing the repository holding the image,
783 * if the repository is private.
784 *
785 * @default no credentials will be used (we assume the repository is public)
786 */
787 readonly secretsManagerCredentials?: secretsmanager.ISecret;
788}
789/**
790 * A CodeBuild image running x86-64 Linux.
791 *
792 * This class has a bunch of public constants that represent the most popular images.
793 *
794 * You can also specify a custom image using one of the static methods:
795 *
796 * - LinuxBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }])
797 * - LinuxBuildImage.fromEcrRepository(repo[, tag])
798 * - LinuxBuildImage.fromAsset(parent, id, props)
799 *
800 *
801 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
802 */
803export declare class LinuxBuildImage implements IBuildImage {
804 static readonly STANDARD_1_0: IBuildImage;
805 static readonly STANDARD_2_0: IBuildImage;
806 static readonly STANDARD_3_0: IBuildImage;
807 /** The `aws/codebuild/standard:4.0` build image. */
808 static readonly STANDARD_4_0: IBuildImage;
809 /** The `aws/codebuild/standard:5.0` build image. */
810 static readonly STANDARD_5_0: IBuildImage;
811 static readonly AMAZON_LINUX_2: IBuildImage;
812 static readonly AMAZON_LINUX_2_2: IBuildImage;
813 /** The Amazon Linux 2 x86_64 standard image, version `3.0`. */
814 static readonly AMAZON_LINUX_2_3: IBuildImage;
815 /** @deprecated Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0 instead. */
816 static readonly AMAZON_LINUX_2_ARM: IBuildImage;
817 /**
818 * Image "aws/codebuild/amazonlinux2-aarch64-standard:2.0".
819 * @deprecated Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0 instead.
820 * */
821 static readonly AMAZON_LINUX_2_ARM_2: IBuildImage;
822 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
823 static readonly UBUNTU_14_04_BASE: IBuildImage;
824 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
825 static readonly UBUNTU_14_04_ANDROID_JAVA8_24_4_1: IBuildImage;
826 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
827 static readonly UBUNTU_14_04_ANDROID_JAVA8_26_1_1: IBuildImage;
828 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
829 static readonly UBUNTU_14_04_DOCKER_17_09_0: IBuildImage;
830 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
831 static readonly UBUNTU_14_04_DOCKER_18_09_0: IBuildImage;
832 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
833 static readonly UBUNTU_14_04_GOLANG_1_10: IBuildImage;
834 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
835 static readonly UBUNTU_14_04_GOLANG_1_11: IBuildImage;
836 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
837 static readonly UBUNTU_14_04_OPEN_JDK_8: IBuildImage;
838 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
839 static readonly UBUNTU_14_04_OPEN_JDK_9: IBuildImage;
840 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
841 static readonly UBUNTU_14_04_OPEN_JDK_11: IBuildImage;
842 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
843 static readonly UBUNTU_14_04_NODEJS_10_14_1: IBuildImage;
844 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
845 static readonly UBUNTU_14_04_NODEJS_10_1_0: IBuildImage;
846 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
847 static readonly UBUNTU_14_04_NODEJS_8_11_0: IBuildImage;
848 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
849 static readonly UBUNTU_14_04_NODEJS_6_3_1: IBuildImage;
850 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
851 static readonly UBUNTU_14_04_PHP_5_6: IBuildImage;
852 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
853 static readonly UBUNTU_14_04_PHP_7_0: IBuildImage;
854 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
855 static readonly UBUNTU_14_04_PHP_7_1: IBuildImage;
856 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
857 static readonly UBUNTU_14_04_PYTHON_3_7_1: IBuildImage;
858 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
859 static readonly UBUNTU_14_04_PYTHON_3_6_5: IBuildImage;
860 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
861 static readonly UBUNTU_14_04_PYTHON_3_5_2: IBuildImage;
862 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
863 static readonly UBUNTU_14_04_PYTHON_3_4_5: IBuildImage;
864 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
865 static readonly UBUNTU_14_04_PYTHON_3_3_6: IBuildImage;
866 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
867 static readonly UBUNTU_14_04_PYTHON_2_7_12: IBuildImage;
868 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
869 static readonly UBUNTU_14_04_RUBY_2_5_3: IBuildImage;
870 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
871 static readonly UBUNTU_14_04_RUBY_2_5_1: IBuildImage;
872 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
873 static readonly UBUNTU_14_04_RUBY_2_3_1: IBuildImage;
874 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
875 static readonly UBUNTU_14_04_RUBY_2_2_5: IBuildImage;
876 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
877 static readonly UBUNTU_14_04_DOTNET_CORE_1_1: IBuildImage;
878 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
879 static readonly UBUNTU_14_04_DOTNET_CORE_2_0: IBuildImage;
880 /** @deprecated Use {@link STANDARD_2_0} and specify runtime in buildspec runtime-versions section */
881 static readonly UBUNTU_14_04_DOTNET_CORE_2_1: IBuildImage;
882 /**
883 * @returns a x86-64 Linux build image from a Docker Hub image.
884 */
885 static fromDockerRegistry(name: string, options?: DockerImageOptions): IBuildImage;
886 /**
887 * @returns A x86-64 Linux build image from an ECR repository.
888 *
889 * NOTE: if the repository is external (i.e. imported), then we won't be able to add
890 * a resource policy statement for it so CodeBuild can pull the image.
891 *
892 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html
893 *
894 * @param repository The ECR repository
895 * @param tagOrDigest Image tag or digest (default "latest", digests must start with `sha256:`)
896 */
897 static fromEcrRepository(repository: ecr.IRepository, tagOrDigest?: string): IBuildImage;
898 /**
899 * Uses an Docker image asset as a x86-64 Linux build image.
900 */
901 static fromAsset(scope: Construct, id: string, props: DockerImageAssetProps): IBuildImage;
902 /**
903 * Uses a Docker image provided by CodeBuild.
904 *
905 * @returns A Docker image provided by CodeBuild.
906 *
907 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
908 *
909 * @param id The image identifier
910 * @example 'aws/codebuild/standard:4.0'
911 */
912 static fromCodeBuildImageId(id: string): IBuildImage;
913 private static codeBuildImage;
914 readonly type = "LINUX_CONTAINER";
915 readonly defaultComputeType = ComputeType.SMALL;
916 readonly imageId: string;
917 readonly imagePullPrincipalType?: ImagePullPrincipalType;
918 readonly secretsManagerCredentials?: secretsmanager.ISecret;
919 readonly repository?: ecr.IRepository;
920 private constructor();
921 validate(_: BuildEnvironment): string[];
922 runScriptBuildspec(entrypoint: string): BuildSpec;
923}
924/**
925 * Environment type for Windows Docker images
926 */
927export declare enum WindowsImageType {
928 /**
929 * The standard environment type, WINDOWS_CONTAINER
930 */
931 STANDARD = "WINDOWS_CONTAINER",
932 /**
933 * The WINDOWS_SERVER_2019_CONTAINER environment type
934 */
935 SERVER_2019 = "WINDOWS_SERVER_2019_CONTAINER"
936}
937/**
938 * A CodeBuild image running Windows.
939 *
940 * This class has a bunch of public constants that represent the most popular images.
941 *
942 * You can also specify a custom image using one of the static methods:
943 *
944 * - WindowsBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }, imageType])
945 * - WindowsBuildImage.fromEcrRepository(repo[, tag, imageType])
946 * - WindowsBuildImage.fromAsset(parent, id, props, [, imageType])
947 *
948 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
949 */
950export declare class WindowsBuildImage implements IBuildImage {
951 /**
952 * Corresponds to the standard CodeBuild image `aws/codebuild/windows-base:1.0`.
953 *
954 * @deprecated `WindowsBuildImage.WINDOWS_BASE_2_0` should be used instead.
955 */
956 static readonly WIN_SERVER_CORE_2016_BASE: IBuildImage;
957 /**
958 * The standard CodeBuild image `aws/codebuild/windows-base:2.0`, which is
959 * based off Windows Server Core 2016.
960 */
961 static readonly WINDOWS_BASE_2_0: IBuildImage;
962 /**
963 * The standard CodeBuild image `aws/codebuild/windows-base:2019-1.0`, which is
964 * based off Windows Server Core 2019.
965 */
966 static readonly WIN_SERVER_CORE_2019_BASE: IBuildImage;
967 /**
968 * @returns a Windows build image from a Docker Hub image.
969 */
970 static fromDockerRegistry(name: string, options?: DockerImageOptions, imageType?: WindowsImageType): IBuildImage;
971 /**
972 * @returns A Windows build image from an ECR repository.
973 *
974 * NOTE: if the repository is external (i.e. imported), then we won't be able to add
975 * a resource policy statement for it so CodeBuild can pull the image.
976 *
977 * @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html
978 *
979 * @param repository The ECR repository
980 * @param tagOrDigest Image tag or digest (default "latest", digests must start with `sha256:`)
981 */
982 static fromEcrRepository(repository: ecr.IRepository, tagOrDigest?: string, imageType?: WindowsImageType): IBuildImage;
983 /**
984 * Uses an Docker image asset as a Windows build image.
985 */
986 static fromAsset(scope: Construct, id: string, props: DockerImageAssetProps, imageType?: WindowsImageType): IBuildImage;
987 readonly type: string;
988 readonly defaultComputeType = ComputeType.MEDIUM;
989 readonly imageId: string;
990 readonly imagePullPrincipalType?: ImagePullPrincipalType;
991 readonly secretsManagerCredentials?: secretsmanager.ISecret;
992 readonly repository?: ecr.IRepository;
993 private constructor();
994 validate(buildEnvironment: BuildEnvironment): string[];
995 runScriptBuildspec(entrypoint: string): BuildSpec;
996}
997export interface BuildEnvironmentVariable {
998 /**
999 * The type of environment variable.
1000 * @default PlainText
1001 */
1002 readonly type?: BuildEnvironmentVariableType;
1003 /**
1004 * The value of the environment variable.
1005 * For plain-text variables (the default), this is the literal value of variable.
1006 * For SSM parameter variables, pass the name of the parameter here (`parameterName` property of `IParameter`).
1007 * For SecretsManager variables secrets, pass either the secret name (`secretName` property of `ISecret`)
1008 * or the secret ARN (`secretArn` property of `ISecret`) here,
1009 * along with optional SecretsManager qualifiers separated by ':', like the JSON key, or the version or stage
1010 * (see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager for details).
1011 */
1012 readonly value: any;
1013}
1014export declare enum BuildEnvironmentVariableType {
1015 /**
1016 * An environment variable in plaintext format.
1017 */
1018 PLAINTEXT = "PLAINTEXT",
1019 /**
1020 * An environment variable stored in Systems Manager Parameter Store.
1021 */
1022 PARAMETER_STORE = "PARAMETER_STORE",
1023 /**
1024 * An environment variable stored in AWS Secrets Manager.
1025 */
1026 SECRETS_MANAGER = "SECRETS_MANAGER"
1027}
1028/**
1029 * The list of event types for AWS Codebuild
1030 * @see https://docs.aws.amazon.com/dtconsole/latest/userguide/concepts.html#events-ref-buildproject
1031 */
1032export declare enum ProjectNotificationEvents {
1033 /**
1034 * Trigger notification when project build state failed
1035 */
1036 BUILD_FAILED = "codebuild-project-build-state-failed",
1037 /**
1038 * Trigger notification when project build state succeeded
1039 */
1040 BUILD_SUCCEEDED = "codebuild-project-build-state-succeeded",
1041 /**
1042 * Trigger notification when project build state in progress
1043 */
1044 BUILD_IN_PROGRESS = "codebuild-project-build-state-in-progress",
1045 /**
1046 * Trigger notification when project build state stopped
1047 */
1048 BUILD_STOPPED = "codebuild-project-build-state-stopped",
1049 /**
1050 * Trigger notification when project build phase failure
1051 */
1052 BUILD_PHASE_FAILED = "codebuild-project-build-phase-failure",
1053 /**
1054 * Trigger notification when project build phase success
1055 */
1056 BUILD_PHASE_SUCCEEDED = "codebuild-project-build-phase-success"
1057}
1058export {};