Skip to content

Commit 1f62c43

Browse files
authored
fix(pipelines): Ubuntu 5 images will be slow, move to Ubuntu 6 (#24544)
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*
1 parent 6a5ae09 commit 1f62c43

File tree

201 files changed

+3401
-2129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+3401
-2129
lines changed

packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { AssetSingletonRole } from '../private/asset-singleton-role';
2222
import { CachedFnSub } from '../private/cached-fnsub';
2323
import { preferredCliVersion } from '../private/cli-version';
2424
import { appOf, assemblyBuilderOf, embeddedAsmPath, obtainScope } from '../private/construct-internals';
25+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../private/default-codebuild-image';
2526
import { toPosixPath } from '../private/fs';
2627
import { actionName, stackVariableNamespace } from '../private/identifiers';
2728
import { enumerate, flatten, maybeSuffix, noUndefined } from '../private/javascript';
@@ -145,7 +146,7 @@ export interface CodePipelineProps {
145146
/**
146147
* Customize the CodeBuild projects created for this pipeline
147148
*
148-
* @default - All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0
149+
* @default - All projects run non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_6_0
149150
*/
150151
readonly codeBuildDefaults?: CodeBuildOptions;
151152

@@ -245,7 +246,7 @@ export interface CodeBuildOptions {
245246
/**
246247
* Partial build environment, will be combined with other build environments that apply
247248
*
248-
* @default - Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0
249+
* @default - Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_6_0
249250
*/
250251
readonly buildEnvironment?: cb.BuildEnvironment;
251252

@@ -833,7 +834,7 @@ export class CodePipeline extends PipelineBase {
833834
private codeBuildDefaultsFor(nodeType: CodeBuildProjectType): CodeBuildOptions | undefined {
834835
const defaultOptions: CodeBuildOptions = {
835836
buildEnvironment: {
836-
buildImage: cb.LinuxBuildImage.STANDARD_5_0,
837+
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
837838
computeType: cb.ComputeType.SMALL,
838839
},
839840
};

packages/@aws-cdk/pipelines/lib/legacy/actions/publish-assets-action.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as iam from '@aws-cdk/aws-iam';
99
import { ISynthesisSession, Lazy, Stack, attachCustomSynthesis } from '@aws-cdk/core';
1010
import { IDependable, Construct } from 'constructs';
1111
import { AssetType } from '../../blueprint/asset-type';
12+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
1213
import { toPosixPath } from '../../private/fs';
1314

1415
/**
@@ -140,7 +141,7 @@ export class PublishAssetsAction extends Construct implements codepipeline.IActi
140141
const project = new codebuild.PipelineProject(this, 'Default', {
141142
projectName: this.props.projectName,
142143
environment: {
143-
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
144+
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
144145
privileged: (props.assetType === AssetType.DOCKER_IMAGE) ? true : undefined,
145146
},
146147
vpc: props.vpc,

packages/@aws-cdk/pipelines/lib/legacy/actions/update-pipeline-action.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Stack } from '@aws-cdk/core';
77
import { Construct } from 'constructs';
88
import { dockerCredentialsInstallCommands, DockerCredential, DockerCredentialUsage } from '../../docker-credentials';
99
import { embeddedAsmPath } from '../../private/construct-internals';
10+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
1011

1112
/**
1213
* Props for the UpdatePipelineAction
@@ -109,7 +110,7 @@ export class UpdatePipelineAction extends Construct implements codepipeline.IAct
109110
const selfMutationProject = new codebuild.PipelineProject(this, 'SelfMutation', {
110111
projectName: props.projectName,
111112
environment: {
112-
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
113+
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
113114
privileged: props.privileged ?? false,
114115
},
115116
buildSpec: props.buildSpec ? codebuild.mergeBuildSpecs(props.buildSpec, buildSpec) : buildSpec,

packages/@aws-cdk/pipelines/lib/legacy/synths/simple-synth-action.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Stack } from '@aws-cdk/core';
1010
import { Construct } from 'constructs';
1111
import { copyEnvironmentVariables, filterEmpty } from './_util';
1212
import { dockerCredentialsInstallCommands, DockerCredential, DockerCredentialUsage } from '../../docker-credentials';
13+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
1314
import { toPosixPath } from '../../private/fs';
1415

1516
const DEFAULT_OUTPUT_DIR = 'cdk.out';
@@ -68,7 +69,7 @@ export interface SimpleSynthOptions {
6869
/**
6970
* Build environment to use for CodeBuild job
7071
*
71-
* @default BuildEnvironment.LinuxBuildImage.STANDARD_5_0
72+
* @default BuildEnvironment.LinuxBuildImage.STANDARD_6_0
7273
*/
7374
readonly environment?: codebuild.BuildEnvironment;
7475

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

343-
const environment = { buildImage: codebuild.LinuxBuildImage.STANDARD_5_0, ...this.props.environment };
344+
const environment = { buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE, ...this.props.environment };
344345
const osType = (environment.buildImage instanceof codebuild.WindowsBuildImage)
345346
? ec2.OperatingSystemType.WINDOWS
346347
: ec2.OperatingSystemType.LINUX;

packages/@aws-cdk/pipelines/lib/legacy/validation/shell-script-action.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as ec2 from '@aws-cdk/aws-ec2';
55
import * as events from '@aws-cdk/aws-events';
66
import * as iam from '@aws-cdk/aws-iam';
77
import { Construct } from 'constructs';
8+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../private/default-codebuild-image';
89
import { StackOutput } from '../stage';
910

1011
/**
@@ -59,7 +60,7 @@ export interface ShellScriptActionProps {
5960
/**
6061
* The CodeBuild environment where scripts are executed.
6162
*
62-
* @default LinuxBuildImage.STANDARD_5_0
63+
* @default LinuxBuildImage.STANDARD_6_0
6364
*/
6465
readonly environment?: codebuild.BuildEnvironment
6566

@@ -195,7 +196,7 @@ export class ShellScriptAction implements codepipeline.IAction, iam.IGrantable {
195196
}
196197

197198
this._project = new codebuild.PipelineProject(scope, 'Project', {
198-
environment: this.props.environment || { buildImage: codebuild.LinuxBuildImage.STANDARD_5_0 },
199+
environment: this.props.environment || { buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE },
199200
vpc: this.props.vpc,
200201
securityGroups: this.props.securityGroups,
201202
subnetSelection: this.props.subnetSelection,

packages/@aws-cdk/pipelines/lib/private/application-security-check.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as iam from '@aws-cdk/aws-iam';
55
import * as lambda from '@aws-cdk/aws-lambda';
66
import { Duration, Tags } from '@aws-cdk/core';
77
import { Construct } from 'constructs';
8+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from './default-codebuild-image';
89

910
/**
1011
* Properties for an ApplicationSecurityCheck
@@ -101,7 +102,7 @@ export class ApplicationSecurityCheck extends Construct {
101102

102103
this.cdkDiffProject = new codebuild.Project(this, 'CDKSecurityCheck', {
103104
environment: {
104-
buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
105+
buildImage: CDKP_DEFAULT_CODEBUILD_IMAGE,
105106
},
106107
buildSpec: codebuild.BuildSpec.fromObject({
107108
version: 0.2,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { LinuxBuildImage } from '@aws-cdk/aws-codebuild';
2+
3+
export const CDKP_DEFAULT_CODEBUILD_IMAGE = LinuxBuildImage.STANDARD_6_0;

packages/@aws-cdk/pipelines/test/compliance/assets.test.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Capture, Match, Template } from '@aws-cdk/assertions';
44
import * as cb from '@aws-cdk/aws-codebuild';
55
import * as ec2 from '@aws-cdk/aws-ec2';
66
import { Stack, Stage } from '@aws-cdk/core';
7+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
78
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, FileAssetApp, MegaAssetsApp, TwoFileAssetsApp, DockerAssetApp, PlainStackApp, stringLike } from '../testhelpers';
89

910
const FILE_ASSET_SOURCE_HASH = '8289faf53c7da377bb2b90615999171adef5e1d8f6b88810e5fef75e6ca09ba5';
@@ -187,7 +188,7 @@ describe('basic pipeline', () => {
187188
function THEN_codePipelineExpectation() {
188189
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
189190
Environment: {
190-
Image: 'aws/codebuild/standard:5.0',
191+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
191192
},
192193
Source: {
193194
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -288,7 +289,7 @@ describe('basic pipeline', () => {
288289
},
289290
Environment: Match.objectLike({
290291
PrivilegedMode: false,
291-
Image: 'aws/codebuild/standard:5.0',
292+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
292293
}),
293294
});
294295
}
@@ -321,7 +322,7 @@ describe('basic pipeline', () => {
321322
})),
322323
},
323324
Environment: Match.objectLike({
324-
Image: 'aws/codebuild/standard:5.0',
325+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
325326
PrivilegedMode: true,
326327
}),
327328
});
@@ -350,7 +351,7 @@ describe('basic pipeline', () => {
350351
function THEN_codePipelineExpectation() {
351352
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
352353
Environment: {
353-
Image: 'aws/codebuild/standard:5.0',
354+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
354355
},
355356
Source: {
356357
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -593,7 +594,7 @@ behavior('can supply pre-install scripts to asset upload', (suite) => {
593594
function THEN_codePipelineExpectation() {
594595
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
595596
Environment: {
596-
Image: 'aws/codebuild/standard:5.0',
597+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
597598
},
598599
Source: {
599600
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -770,7 +771,7 @@ describe('pipeline with single asset publisher', () => {
770771
});
771772
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
772773
Environment: {
773-
Image: 'aws/codebuild/standard:5.0',
774+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
774775
},
775776
Source: {
776777
BuildSpec: buildSpecName,
@@ -898,7 +899,7 @@ describe('pipeline with custom asset publisher BuildSpec', () => {
898899
});
899900
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
900901
Environment: {
901-
Image: 'aws/codebuild/standard:5.0',
902+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
902903
},
903904
Source: {
904905
BuildSpec: buildSpecName,

packages/@aws-cdk/pipelines/test/compliance/docker-credentials.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Stack } from '@aws-cdk/core';
55
import { Construct } from 'constructs';
66
import * as cdkp from '../../lib';
77
import { CodeBuildStep } from '../../lib';
8+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
89
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, DockerAssetApp, stringLike } from '../testhelpers';
910

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

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

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

222223
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
223-
Environment: { Image: 'aws/codebuild/standard:5.0' },
224+
Environment: { Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId },
224225
Source: {
225226
BuildSpec: Match.serializedJson(Match.objectLike({
226227
phases: {

packages/@aws-cdk/pipelines/test/compliance/security-check.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Match, Template } from '@aws-cdk/assertions';
22
import { Topic } from '@aws-cdk/aws-sns';
33
import { Stack } from '@aws-cdk/core';
44
import * as cdkp from '../../lib';
5+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
56
import { LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, OneStackApp, PIPELINE_ENV, TestApp, stringLike } from '../testhelpers';
67
import { behavior } from '../testhelpers/compliance';
78

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

56-
// No CodeBuild project has a build image that is not standard:5.0
57+
// No CodeBuild project has a build image that is not the standard iamge
5758
const projects = template.findResources('AWS::CodeBuild::Project', {
5859
Properties: {
5960
Environment: {
60-
Image: 'aws/codebuild/standard:5.0',
61+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
6162
},
6263
},
6364
});

packages/@aws-cdk/pipelines/test/compliance/self-mutation.test.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Match, Template } from '@aws-cdk/assertions';
33
import * as cb from '@aws-cdk/aws-codebuild';
44
import * as cp from '@aws-cdk/aws-codepipeline';
55
import { Stack, Stage } from '@aws-cdk/core';
6+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
67
import { behavior, LegacyTestGitHubNpmPipeline, PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline } from '../testhelpers';
78

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

4748
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
4849
Environment: {
49-
Image: 'aws/codebuild/standard:5.0',
50+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
5051
},
5152
Source: {
5253
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -85,7 +86,7 @@ behavior('selfmutation stage correctly identifies nested assembly of pipeline st
8586
function THEN_codePipelineExpectation(nestedPipelineStack: Stack) {
8687
Template.fromStack(nestedPipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
8788
Environment: {
88-
Image: 'aws/codebuild/standard:5.0',
89+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
8990
},
9091
Source: {
9192
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -281,7 +282,7 @@ behavior('self-mutation stage can be customized with BuildSpec', (suite) => {
281282
function THEN_codePipelineExpectation() {
282283
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
283284
Environment: {
284-
Image: 'aws/codebuild/standard:5.0',
285+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
285286
PrivilegedMode: false,
286287
},
287288
Source: {

packages/@aws-cdk/pipelines/test/compliance/synths.test.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as s3 from '@aws-cdk/aws-s3';
88
import { Stack } from '@aws-cdk/core';
99
import * as cdkp from '../../lib';
1010
import { CodeBuildStep } from '../../lib';
11+
import { CDKP_DEFAULT_CODEBUILD_IMAGE } from '../../lib/private/default-codebuild-image';
1112
import { behavior, PIPELINE_ENV, TestApp, LegacyTestGitHubNpmPipeline, ModernTestGitHubNpmPipeline, ModernTestGitHubNpmPipelineProps, OneStackApp } from '../testhelpers';
1213

1314
let app: TestApp;
@@ -65,7 +66,7 @@ behavior('synth takes arrays of commands', (suite) => {
6566
// THEN
6667
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
6768
Environment: {
68-
Image: 'aws/codebuild/standard:5.0',
69+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
6970
},
7071
Source: {
7172
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -113,7 +114,7 @@ behavior('synth sets artifact base-directory to cdk.out', (suite) => {
113114
// THEN
114115
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
115116
Environment: {
116-
Image: 'aws/codebuild/standard:5.0',
117+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
117118
},
118119
Source: {
119120
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -155,7 +156,7 @@ behavior('synth supports setting subdirectory', (suite) => {
155156
// THEN
156157
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
157158
Environment: {
158-
Image: 'aws/codebuild/standard:5.0',
159+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
159160
},
160161
Source: {
161162
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -226,7 +227,7 @@ behavior('synth assumes a JavaScript project by default (no build, yes synth)',
226227
// THEN
227228
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
228229
Environment: {
229-
Image: 'aws/codebuild/standard:5.0',
230+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
230231
},
231232
Source: {
232233
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -414,7 +415,7 @@ behavior('install command can be overridden/specified', (suite) => {
414415
// THEN
415416
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
416417
Environment: {
417-
Image: 'aws/codebuild/standard:5.0',
418+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
418419
},
419420
Source: {
420421
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -446,7 +447,7 @@ behavior('synth can have its test commands set', (suite) => {
446447
// THEN
447448
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
448449
Environment: {
449-
Image: 'aws/codebuild/standard:5.0',
450+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
450451
},
451452
Source: {
452453
BuildSpec: Match.serializedJson(Match.objectLike({
@@ -507,7 +508,7 @@ behavior('Synth can output additional artifacts', (suite) => {
507508
// THEN
508509
Template.fromStack(pipelineStack).hasResourceProperties('AWS::CodeBuild::Project', {
509510
Environment: {
510-
Image: 'aws/codebuild/standard:5.0',
511+
Image: CDKP_DEFAULT_CODEBUILD_IMAGE.imageId,
511512
},
512513
Source: {
513514
BuildSpec: Match.serializedJson(Match.objectLike({

0 commit comments

Comments
 (0)