Skip to content

Commit

Permalink
fix(pipelines): Ubuntu 5 images will be slow, move to Ubuntu 6 (aws#2…
Browse files Browse the repository at this point in the history
…4544)

CodeBuild has moved the `STANDARD_5` images to the slow path, meaning they will not be cached on the host anymore. Every customer using CDK Pipelines has gotten an email about this.

Move the CDK Pipelines default image to `STANDARD_6`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored and homakk committed Mar 28, 2023
1 parent 6d2853f commit 4023120
Show file tree
Hide file tree
Showing 201 changed files with 3,401 additions and 2,129 deletions.
7 changes: 4 additions & 3 deletions packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline.ts
Expand Up @@ -22,6 +22,7 @@ import { AssetSingletonRole } from '../private/asset-singleton-role';
import { CachedFnSub } from '../private/cached-fnsub';
import { preferredCliVersion } from '../private/cli-version';
import { appOf, assemblyBuilderOf, embeddedAsmPath, obtainScope } from '../private/construct-internals';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../private/default-codebuild-image';
import { toPosixPath } from '../private/fs';
import { actionName, stackVariableNamespace } from '../private/identifiers';
import { enumerate, flatten, maybeSuffix, noUndefined } from '../private/javascript';
Expand Down Expand Up @@ -145,7 +146,7 @@ export interface CodePipelineProps {
/**
* Customize the CodeBuild projects created for this pipeline
*
* @default - All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0
* @default - All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_6_0
*/
readonly codeBuildDefaults?: CodeBuildOptions;

Expand Down Expand Up @@ -245,7 +246,7 @@ export interface CodeBuildOptions {
/**
* Partial build environment, will be combined with other build environments that apply
*
* @default - Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0
* @default - Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_6_0
*/
readonly buildEnvironment?: cb.BuildEnvironment;

Expand Down Expand Up @@ -833,7 +834,7 @@ export class CodePipeline extends PipelineBase {
private codeBuildDefaultsFor(nodeType: CodeBuildProjectType): CodeBuildOptions | undefined {
const defaultOptions: CodeBuildOptions = {
buildEnvironment: {
buildImage: cb.LinuxBuildImage.STANDARD_5_0,
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
computeType: cb.ComputeType.SMALL,
},
};
Expand Down
Expand Up @@ -9,6 +9,7 @@ import * as iam from '@aws-cdk/aws-iam';
import { ISynthesisSession, Lazy, Stack, attachCustomSynthesis } from '@aws-cdk/core';
import { IDependable, Construct } from 'constructs';
import { AssetType } from '../../blueprint/asset-type';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
import { toPosixPath } from '../../private/fs';

/**
Expand Down Expand Up @@ -140,7 +141,7 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi
const project = new codebuild.PipelineProject(this, 'Default', {
projectName: this.props.projectName,
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
privileged: (props.assetType === AssetType.DOCKER_IMAGE) ? true : undefined,
},
vpc: props.vpc,
Expand Down
Expand Up @@ -7,6 +7,7 @@ import { Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { dockerCredentialsInstallCommands, DockerCredential, DockerCredentialUsage } from '../../docker-credentials';
import { embeddedAsmPath } from '../../private/construct-internals';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';

/**
* Props for the UpdatePipelineAction
Expand Down Expand Up @@ -109,7 +110,7 @@ export class UpdatePipelineAction extends Construct implements codepipeline.IAct
const selfMutationProject = new codebuild.PipelineProject(this, 'SelfMutation', {
projectName: props.projectName,
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
privileged: props.privileged ?? false,
},
buildSpec: props.buildSpec ? codebuild.mergeBuildSpecs(props.buildSpec, buildSpec) : buildSpec,
Expand Down
Expand Up @@ -10,6 +10,7 @@ import { Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { copyEnvironmentVariables, filterEmpty } from './_util';
import { dockerCredentialsInstallCommands, DockerCredential, DockerCredentialUsage } from '../../docker-credentials';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
import { toPosixPath } from '../../private/fs';

const DEFAULT_OUTPUT_DIR = 'cdk.out';
Expand Down Expand Up @@ -68,7 +69,7 @@ export interface SimpleSynthOptions {
/**
* Build environment to use for CodeBuild job
*
* @default BuildEnvironment.LinuxBuildImage.STANDARD_5_0
* @default BuildEnvironment.LinuxBuildImage.STANDARD_6_0
*/
readonly environment?: codebuild.BuildEnvironment;

Expand Down Expand Up @@ -340,7 +341,7 @@ export class SimpleSynthAction implements codepipeline.IAction, iam.IGrantable {
const testCommands = this.props.testCommands ?? [];
const synthCommand = this.props.synthCommand;

const environment = { buildImage: codebuild.LinuxBuildImage.STANDARD_5_0, ...this.props.environment };
const environment = { buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE, ...this.props.environment };
const osType = (environment.buildImage instanceof codebuild.WindowsBuildImage)
? ec2.OperatingSystemType.WINDOWS
: ec2.OperatingSystemType.LINUX;
Expand Down
Expand Up @@ -5,6 +5,7 @@ import * as ec2 from '@aws-cdk/aws-ec2';
import * as events from '@aws-cdk/aws-events';
import * as iam from '@aws-cdk/aws-iam';
import { Construct } from 'constructs';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
import { StackOutput } from '../stage';

/**
Expand Down Expand Up @@ -59,7 +60,7 @@ export interface ShellScriptActionProps {
/**
* The CodeBuild environment where scripts are executed.
*
* @default LinuxBuildImage.STANDARD_5_0
* @default LinuxBuildImage.STANDARD_6_0
*/
readonly environment?: codebuild.BuildEnvironment

Expand Down Expand Up @@ -195,7 +196,7 @@ export class ShellScriptAction implements codepipeline.IAction, iam.IGrantable {
}

this._project = new codebuild.PipelineProject(scope, 'Project', {
environment: this.props.environment || { buildImage: codebuild.LinuxBuildImage.STANDARD_5_0 },
environment: this.props.environment || { buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE },
vpc: this.props.vpc,
securityGroups: this.props.securityGroups,
subnetSelection: this.props.subnetSelection,
Expand Down
Expand Up @@ -5,6 +5,7 @@ import * as iam from '@aws-cdk/aws-iam';
import * as lambda from '@aws-cdk/aws-lambda';
import { Duration, Tags } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from './default-codebuild-image';

/**
* Properties for an ApplicationSecurityCheck
Expand Down Expand Up @@ -101,7 +102,7 @@ export class ApplicationSecurityCheck extends Construct {

this.cdkDiffProject = new codebuild.Project(this, 'CDKSecurityCheck', {
environment: {
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
},
buildSpec: codebuild.BuildSpec.fromObject({
version: 0.2,
Expand Down
@@ -0,0 +1,3 @@
import { LinuxBuildImage } from '@aws-cdk/aws-codebuild';

export const CDKP_DEFAULT_CODEBUILD_IMAGE = LinuxBuildImage.STANDARD_6_0;
15 changes: 8 additions & 7 deletions packages/@aws-cdk/pipelines/test/compliance/assets.test.ts
Expand Up @@ -4,6 +4,7 @@ import { Capture, Match, Template } from '@aws-cdk/assertions';
import * as cb from '@aws-cdk/aws-codebuild';
import * as ec2 from '@aws-cdk/aws-ec2';
import { Stack, Stage } from '@aws-cdk/core';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, FileAssetApp, MegaAssetsApp, TwoFileAssetsApp, DockerAssetApp, PlainStackApp, stringLike } from '../testhelpers';

const FILE_ASSET_SOURCE_HASH = '8289faf53c7da377bb2b90615999171adef5e1d8f6b88810e5fef75e6ca09ba5';
Expand Down Expand Up @@ -187,7 +188,7 @@ describe('basic pipeline', () => {
function THEN_codePipelineExpectation() {
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -288,7 +289,7 @@ describe('basic pipeline', () => {
},
Environment: Match.objectLike({
PrivilegedMode: false,
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
}),
});
}
Expand Down Expand Up @@ -321,7 +322,7 @@ describe('basic pipeline', () => {
})),
},
Environment: Match.objectLike({
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
PrivilegedMode: true,
}),
});
Expand Down Expand Up @@ -350,7 +351,7 @@ describe('basic pipeline', () => {
function THEN_codePipelineExpectation() {
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -593,7 +594,7 @@ behavior('can supply pre-install scripts to asset upload', (suite) => {
function THEN_codePipelineExpectation() {
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -770,7 +771,7 @@ describe('pipeline with single asset publisher', () => {
});
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: buildSpecName,
Expand Down Expand Up @@ -898,7 +899,7 @@ describe('pipeline with custom asset publisher BuildSpec', () => {
});
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: buildSpecName,
Expand Down
Expand Up @@ -5,6 +5,7 @@ import { Stack } from '@aws-cdk/core';
import { Construct } from 'constructs';
import * as cdkp from '../../lib';
import { CodeBuildStep } from '../../lib';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, DockerAssetApp, stringLike } from '../testhelpers';

const secretSynthArn = 'arn:aws:secretsmanager:eu-west-1:0123456789012:secret:synth-012345';
Expand Down Expand Up @@ -51,7 +52,7 @@ behavior('synth action receives install commands and access to relevant credenti
});

Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: { Image: 'aws/codebuild/standard:5.0' },
Environment: { Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId },
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
phases: {
Expand Down Expand Up @@ -164,7 +165,7 @@ behavior('self-update receives install commands and access to relevant credentia
});

Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: { Image: 'aws/codebuild/standard:5.0' },
Environment: { Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId },
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
phases: {
Expand Down Expand Up @@ -220,7 +221,7 @@ behavior('asset publishing receives install commands and access to relevant cred
});

Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: { Image: 'aws/codebuild/standard:5.0' },
Environment: { Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId },
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
phases: {
Expand Down
Expand Up @@ -2,6 +2,7 @@ import { Match, Template } from '@aws-cdk/assertions';
import { Topic } from '@aws-cdk/aws-sns';
import { Stack } from '@aws-cdk/core';
import * as cdkp from '../../lib';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
import { LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, OneStackApp, PIPELINE_ENV, TestApp, stringLike } from '../testhelpers';
import { behavior } from '../testhelpers/compliance';

Expand Down Expand Up @@ -53,11 +54,11 @@ behavior('security check option generates lambda/codebuild at pipeline scope', (
// 1 for github build, 1 for synth stage, and 1 for the application security check
template.resourceCountIs('AWS::CodeBuild::Project', 3);

// No CodeBuild project has a build image that is not standard:5.0
// No CodeBuild project has a build image that is not the standard iamge
const projects = template.findResources('AWS::CodeBuild::Project', {
Properties: {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
},
});
Expand Down
Expand Up @@ -3,6 +3,7 @@ import { Match, Template } from '@aws-cdk/assertions';
import * as cb from '@aws-cdk/aws-codebuild';
import * as cp from '@aws-cdk/aws-codepipeline';
import { Stack, Stage } from '@aws-cdk/core';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
import { behavior, LegacyTestGitHubNpmPipeline, PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline } from '../testhelpers';

let app: TestApp;
Expand Down Expand Up @@ -46,7 +47,7 @@ behavior('CodePipeline has self-mutation stage', (suite) => {

Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -85,7 +86,7 @@ behavior('selfmutation stage correctly identifies nested assembly of pipeline st
function THEN_codePipelineExpectation(nestedPipelineStack: Stack) {
Template.fromStack(nestedPipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -281,7 +282,7 @@ behavior('self-mutation stage can be customized with BuildSpec', (suite) => {
function THEN_codePipelineExpectation() {
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
PrivilegedMode: false,
},
Source: {
Expand Down
15 changes: 8 additions & 7 deletions packages/@aws-cdk/pipelines/test/compliance/synths.test.ts
Expand Up @@ -8,6 +8,7 @@ import * as s3 from '@aws-cdk/aws-s3';
import { Stack } from '@aws-cdk/core';
import * as cdkp from '../../lib';
import { CodeBuildStep } from '../../lib';
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, ModernTestGitHubNpmPipelineProps, OneStackApp } from '../testhelpers';

let app: TestApp;
Expand Down Expand Up @@ -65,7 +66,7 @@ behavior('synth takes arrays of commands', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -113,7 +114,7 @@ behavior('synth sets artifact base-directory to cdk.out', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -155,7 +156,7 @@ behavior('synth supports setting subdirectory', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -226,7 +227,7 @@ behavior('synth assumes a JavaScript project by default (no build, yes synth)',
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -414,7 +415,7 @@ behavior('install command can be overridden/specified', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -446,7 +447,7 @@ behavior('synth can have its test commands set', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down Expand Up @@ -507,7 +508,7 @@ behavior('Synth can output additional artifacts', (suite) => {
// THEN
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
Environment: {
Image: 'aws/codebuild/standard:5.0',
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
},
Source: {
BuildSpec: Match.serializedJson(Match.objectLike({
Expand Down

0 comments on commit 4023120

Please sign in to comment.