-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into iotevents-rest-events
- Loading branch information
Showing
39 changed files
with
983 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
packages/@aws-cdk/aws-codebuild/lib/linux-arm-build-image.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import * as ecr from '@aws-cdk/aws-ecr'; | ||
import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; | ||
import { BuildSpec } from './build-spec'; | ||
import { runScriptLinuxBuildSpec } from './private/run-script-linux-build-spec'; | ||
import { BuildEnvironment, ComputeType, IBuildImage, ImagePullPrincipalType } from './project'; | ||
|
||
/** | ||
* Construction properties of {@link LinuxArmBuildImage}. | ||
* Module-private, as the constructor of {@link LinuxArmBuildImage} is private. | ||
*/ | ||
interface LinuxArmBuildImageProps { | ||
readonly imageId: string; | ||
readonly imagePullPrincipalType?: ImagePullPrincipalType; | ||
readonly secretsManagerCredentials?: secretsmanager.ISecret; | ||
readonly repository?: ecr.IRepository; | ||
} | ||
|
||
/** | ||
* A CodeBuild image running aarch64 Linux. | ||
* | ||
* This class has a bunch of public constants that represent the CodeBuild ARM images. | ||
* | ||
* You can also specify a custom image using the static method: | ||
* | ||
* - LinuxBuildImage.fromEcrRepository(repo[, tag]) | ||
* | ||
* | ||
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html | ||
*/ | ||
export class LinuxArmBuildImage implements IBuildImage { | ||
/** Image "aws/codebuild/amazonlinux2-aarch64-standard:1.0". */ | ||
public static readonly AMAZON_LINUX_2_STANDARD_1_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-aarch64-standard:1.0'); | ||
/** Image "aws/codebuild/amazonlinux2-aarch64-standard:2.0". */ | ||
public static readonly AMAZON_LINUX_2_STANDARD_2_0 = LinuxArmBuildImage.fromCodeBuildImageId('aws/codebuild/amazonlinux2-aarch64-standard:2.0'); | ||
|
||
/** | ||
* Returns an ARM image running Linux from an ECR repository. | ||
* | ||
* NOTE: if the repository is external (i.e. imported), then we won't be able to add | ||
* a resource policy statement for it so CodeBuild can pull the image. | ||
* | ||
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html | ||
* | ||
* @param repository The ECR repository | ||
* @param tag Image tag (default "latest") | ||
* @returns An aarch64 Linux build image from an ECR repository. | ||
*/ | ||
public static fromEcrRepository(repository: ecr.IRepository, tag: string = 'latest'): IBuildImage { | ||
return new LinuxArmBuildImage({ | ||
imageId: repository.repositoryUriForTag(tag), | ||
imagePullPrincipalType: ImagePullPrincipalType.SERVICE_ROLE, | ||
repository, | ||
}); | ||
} | ||
|
||
/** | ||
* Uses a Docker image provided by CodeBuild. | ||
* | ||
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html | ||
* | ||
* @param id The image identifier | ||
* @example 'aws/codebuild/amazonlinux2-aarch64-standard:1.0' | ||
* @returns A Docker image provided by CodeBuild. | ||
*/ | ||
public static fromCodeBuildImageId(id: string): IBuildImage { | ||
return new LinuxArmBuildImage({ | ||
imageId: id, | ||
imagePullPrincipalType: ImagePullPrincipalType.CODEBUILD, | ||
}); | ||
} | ||
|
||
public readonly type = 'ARM_CONTAINER'; | ||
public readonly defaultComputeType = ComputeType.LARGE; | ||
public readonly imageId: string; | ||
public readonly imagePullPrincipalType?: ImagePullPrincipalType; | ||
public readonly secretsManagerCredentials?: secretsmanager.ISecret; | ||
public readonly repository?: ecr.IRepository; | ||
|
||
private constructor(props: LinuxArmBuildImageProps) { | ||
this.imageId = props.imageId; | ||
this.imagePullPrincipalType = props.imagePullPrincipalType; | ||
this.secretsManagerCredentials = props.secretsManagerCredentials; | ||
this.repository = props.repository; | ||
} | ||
|
||
/** | ||
* Validates by checking the BuildEnvironment computeType as aarch64 images only support ComputeType.SMALL and | ||
* ComputeType.LARGE | ||
* @param buildEnvironment BuildEnvironment | ||
*/ | ||
public validate(buildEnvironment: BuildEnvironment): string[] { | ||
const ret = []; | ||
if (buildEnvironment.computeType && | ||
buildEnvironment.computeType !== ComputeType.SMALL && | ||
buildEnvironment.computeType !== ComputeType.LARGE) { | ||
ret.push(`ARM images only support ComputeTypes '${ComputeType.SMALL}' and '${ComputeType.LARGE}' - ` + | ||
`'${buildEnvironment.computeType}' was given`); | ||
} | ||
return ret; | ||
} | ||
|
||
public runScriptBuildspec(entrypoint: string): BuildSpec { | ||
return runScriptLinuxBuildSpec(entrypoint); | ||
} | ||
} |
Oops, something went wrong.