From 7803e066b1e9b47112433a0596139a5ed63faf34 Mon Sep 17 00:00:00 2001 From: "Kenta Goto (k.goto)" <24818752+go-to-k@users.noreply.github.com> Date: Fri, 30 Aug 2024 03:34:08 +0900 Subject: [PATCH 1/3] chore(cloudfront): add validation for length of comment in cache policy (#31251) ### Issue # (if applicable) Closes #31248 . ### Reason for this change CDK doesn't validate the comment's length in the cache policy now. ### Description of changes Add validation for the length. ### Description of how you validated changes unit tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts | 7 +++++++ .../aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts b/packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts index ab123d9949f54..c9e1e94af0a00 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/lib/cache-policy.ts @@ -26,6 +26,9 @@ export interface CachePolicyProps { /** * A comment to describe the cache policy. + * + * The comment cannot be longer than 128 characters. + * * @default - no comment */ readonly comment?: string; @@ -149,6 +152,10 @@ export class CachePolicy extends Resource implements ICachePolicy { throw new Error(`'cachePolicyName' cannot be longer than 128 characters, got: '${cachePolicyName.length}'`); } + if (props.comment && !Token.isUnresolved(props.comment) && props.comment.length > 128) { + throw new Error(`'comment' cannot be longer than 128 characters, got: ${props.comment.length}`); + } + const minTtl = (props.minTtl ?? Duration.seconds(0)).toSeconds(); let defaultTtl = (props.defaultTtl ?? Duration.days(1)).toSeconds(); let maxTtl = (props.maxTtl ?? Duration.days(365)).toSeconds(); diff --git a/packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts b/packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts index bd30650bc0ea5..44bfd52d19c84 100644 --- a/packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts +++ b/packages/aws-cdk-lib/aws-cloudfront/test/cache-policy.test.ts @@ -108,6 +108,11 @@ describe('CachePolicy', () => { })).not.toThrow(); }); + test('throws on long comment over 128 characters', () => { + const errorMessage = /'comment' cannot be longer than 128 characters, got: 129/; + expect(() => new CachePolicy(stack, 'CachePolicy1', { comment: 'a'.repeat(129) })).toThrow(errorMessage); + }); + describe('TTLs', () => { test('default TTLs', () => { new CachePolicy(stack, 'CachePolicy', { cachePolicyName: 'MyPolicy' }); From 6ed0bed61088765b9f0aa736d7daea4cbea05b3d Mon Sep 17 00:00:00 2001 From: Ian Kerins Date: Thu, 29 Aug 2024 15:41:53 -0400 Subject: [PATCH 2/3] feat(ec2): support throughput on LaunchTemplate EBS volumes (#30716) ### Issue # (if applicable) Fixes #24341. ### Reason for this change You currently can't specify `throughput` on LaunchTemplate EBS volumes. ### Description of changes This support was simply not included in ec2 when it was added to autoscaling in #22441. I have copied that PR's implementation implementation to ec2 and similarly adapted its tests. ### Description of how you validated changes Unit and integration tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-cdk-ec2-lt-metadata-1.assets.json | 4 +- .../aws-cdk-ec2-lt-metadata-1.template.json | 10 ++ .../manifest.json | 2 +- .../tree.json | 114 ++++++++++-------- .../aws-ec2/test/integ.launch-template.ts | 7 ++ packages/aws-cdk-lib/aws-ec2/README.md | 27 +++++ .../aws-ec2/lib/private/ebs-util.ts | 25 +++- packages/aws-cdk-lib/aws-ec2/lib/volume.ts | 14 +++ .../aws-ec2/test/launch-template.test.ts | 69 +++++++++++ 9 files changed, 216 insertions(+), 56 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json index 1147a2215bf03..50966c176342c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json @@ -14,7 +14,7 @@ } } }, - "8cd8c63d04ed01a1a76f21f94fa840809a354a12b00cfac1a16d1bfb8973a85a": { + "dda69b9afcec994df7f53332da5d81f218d4a807b31eab3bc506b1de934caa47": { "source": { "path": "aws-cdk-ec2-lt-metadata-1.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "8cd8c63d04ed01a1a76f21f94fa840809a354a12b00cfac1a16d1bfb8973a85a.json", + "objectKey": "dda69b9afcec994df7f53332da5d81f218d4a807b31eab3bc506b1de934caa47.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json index 061a117dbcb13..afcce2141c2cd 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json @@ -159,6 +159,16 @@ "Type": "AWS::EC2::LaunchTemplate", "Properties": { "LaunchTemplateData": { + "BlockDeviceMappings": [ + { + "DeviceName": "/dev/xvda", + "Ebs": { + "Throughput": 250, + "VolumeSize": 15, + "VolumeType": "gp3" + } + } + ], "MetadataOptions": { "HttpEndpoint": "enabled", "HttpProtocolIpv6": "enabled", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json index 92489c9202eb6..ba6fd0b3cfa1f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8cd8c63d04ed01a1a76f21f94fa840809a354a12b00cfac1a16d1bfb8973a85a.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/dda69b9afcec994df7f53332da5d81f218d4a807b31eab3bc506b1de934caa47.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json index ed2fedb904e4d..2df32814c1143 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json @@ -31,8 +31,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" } }, "RestrictDefaultSecurityGroupCustomResource": { @@ -43,28 +43,28 @@ "id": "Default", "path": "aws-cdk-ec2-lt-metadata-1/MyVpc/RestrictDefaultSecurityGroupCustomResource/Default", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" } }, "LatestNodeRuntimeMap": { "id": "LatestNodeRuntimeMap", "path": "aws-cdk-ec2-lt-metadata-1/LatestNodeRuntimeMap", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnMapping", + "version": "0.0.0" } }, "Custom::VpcRestrictDefaultSGCustomResourceProvider": { @@ -75,30 +75,30 @@ "id": "Staging", "path": "aws-cdk-ec2-lt-metadata-1/Custom::VpcRestrictDefaultSGCustomResourceProvider/Staging", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" } }, "Role": { "id": "Role", "path": "aws-cdk-ec2-lt-metadata-1/Custom::VpcRestrictDefaultSGCustomResourceProvider/Role", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } }, "Handler": { "id": "Handler", "path": "aws-cdk-ec2-lt-metadata-1/Custom::VpcRestrictDefaultSGCustomResourceProvider/Handler", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CustomResourceProviderBase", + "version": "0.0.0" } }, "sg1": { @@ -125,14 +125,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" } }, "LT": { @@ -146,6 +146,16 @@ "aws:cdk:cloudformation:type": "AWS::EC2::LaunchTemplate", "aws:cdk:cloudformation:props": { "launchTemplateData": { + "blockDeviceMappings": [ + { + "deviceName": "/dev/xvda", + "ebs": { + "volumeSize": 15, + "throughput": 250, + "volumeType": "gp3" + } + } + ], "securityGroupIds": [ { "Fn::GetAtt": [ @@ -203,14 +213,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.CfnLaunchTemplate", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.LaunchTemplate", + "version": "0.0.0" } }, "sg2": { @@ -237,14 +247,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" } }, "LTWithMachineImage": { @@ -299,52 +309,52 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.CfnLaunchTemplate", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_ec2.LaunchTemplate", + "version": "0.0.0" } }, "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", "path": "aws-cdk-ec2-lt-metadata-1/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", "path": "aws-cdk-ec2-lt-metadata-1/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn2-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "aws-cdk-ec2-lt-metadata-1/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "aws-cdk-ec2-lt-metadata-1/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } }, "LambdaTest": { @@ -371,22 +381,22 @@ "id": "BootstrapVersion", "path": "LambdaTest/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "LambdaTest/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } } }, @@ -411,8 +421,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts index 0aa48e0277a81..99d3922ec790b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts @@ -23,6 +23,13 @@ const lt = new ec2.LaunchTemplate(stack, 'LT', { httpTokens: ec2.LaunchTemplateHttpTokens.REQUIRED, instanceMetadataTags: true, securityGroup: sg1, + blockDevices: [{ + deviceName: '/dev/xvda', + volume: ec2.BlockDeviceVolume.ebs(15, { + volumeType: ec2.EbsDeviceVolumeType.GP3, + throughput: 250, + }), + }], }); const sg2 = new ec2.SecurityGroup(stack, 'sg2', { diff --git a/packages/aws-cdk-lib/aws-ec2/README.md b/packages/aws-cdk-lib/aws-ec2/README.md index 6e014062f87d1..2e380cedc1f18 100644 --- a/packages/aws-cdk-lib/aws-ec2/README.md +++ b/packages/aws-cdk-lib/aws-ec2/README.md @@ -1603,6 +1603,33 @@ new ec2.Instance(this, 'Instance', { ``` +To specify the throughput value for `gp3` volumes, use the `throughput` property: + +```ts +declare const vpc: ec2.Vpc; +declare const instanceType: ec2.InstanceType; +declare const machineImage: ec2.IMachineImage; + +new ec2.Instance(this, 'Instance', { + vpc, + instanceType, + machineImage, + + // ... + + blockDevices: [ + { + deviceName: '/dev/sda1', + volume: ec2.BlockDeviceVolume.ebs(100, { + volumeType: ec2.EbsDeviceVolumeType.GP3, + throughput: 250, + }), + }, + ], +}); + +``` + #### EBS Optimized Instances An Amazon EBS–optimized instance uses an optimized configuration stack and provides additional, dedicated capacity for Amazon EBS I/O. This optimization provides the best performance for your EBS volumes by minimizing contention between Amazon EBS I/O and other traffic from your instance. diff --git a/packages/aws-cdk-lib/aws-ec2/lib/private/ebs-util.ts b/packages/aws-cdk-lib/aws-ec2/lib/private/ebs-util.ts index 51a020fa1036f..2f6d4c59a432c 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/private/ebs-util.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/private/ebs-util.ts @@ -25,7 +25,29 @@ function synthesizeBlockDeviceMappings(construct: Construct, blockDevic if (ebs) { - const { iops, volumeType, kmsKey, ...rest } = ebs; + const { iops, throughput, volumeType, kmsKey, ...rest } = ebs; + + if (throughput) { + if (volumeType !== EbsDeviceVolumeType.GP3) { + throw new Error(`'throughput' requires 'volumeType': ${EbsDeviceVolumeType.GP3}, got: ${volumeType}.`); + } + + if (!Number.isInteger(throughput)) { + throw new Error(`'throughput' must be an integer, got: ${throughput}.`); + } + + if (throughput < 125 || throughput > 1000) { + throw new Error(`'throughput' must be between 125 and 1000, got ${throughput}.`); + } + + const maximumThroughputRatio = 0.25; + if (iops) { + const iopsRatio = (throughput / iops); + if (iopsRatio > maximumThroughputRatio) { + throw new Error(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops`); + } + } + } if (!iops) { if (volumeType === EbsDeviceVolumeType.IO1 || volumeType === EbsDeviceVolumeType.IO2) { @@ -43,6 +65,7 @@ function synthesizeBlockDeviceMappings(construct: Construct, blockDevic finalEbs = { ...rest, iops, + throughput, volumeType, kmsKeyId: kmsKey?.keyArn, }; diff --git a/packages/aws-cdk-lib/aws-ec2/lib/volume.ts b/packages/aws-cdk-lib/aws-ec2/lib/volume.ts index 70d19b119f717..d284e8ef81dbb 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/volume.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/volume.ts @@ -70,6 +70,20 @@ export interface EbsDeviceOptionsBase { * `@aws-cdk/aws-ec2:ebsDefaultGp3Volume` is enabled. */ readonly volumeType?: EbsDeviceVolumeType; + + /** + * The throughput to provision for a `gp3` volume. + * + * Valid Range: Minimum value of 125. Maximum value of 1000. + * + * `gp3` volumes deliver a consistent baseline throughput performance of 125 MiB/s. + * You can provision additional throughput for an additional cost at a ratio of 0.25 MiB/s per provisioned IOPS. + * + * @see https://docs.aws.amazon.com/ebs/latest/userguide/general-purpose.html#gp3-performance + * + * @default - 125 MiB/s. + */ + readonly throughput?: number; } /** diff --git a/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts b/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts index a818c23b8f1cb..d277cdaaf1bbc 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/launch-template.test.ts @@ -336,6 +336,12 @@ describe('LaunchTemplate', () => { }, { deviceName: 'ephemeral', volume: BlockDeviceVolume.ephemeral(0), + }, { + deviceName: 'gp3-with-throughput', + volume: BlockDeviceVolume.ebs(15, { + volumeType: EbsDeviceVolumeType.GP3, + throughput: 350, + }), }, ]; @@ -388,10 +394,73 @@ describe('LaunchTemplate', () => { DeviceName: 'ephemeral', VirtualName: 'ephemeral0', }, + { + DeviceName: 'gp3-with-throughput', + Ebs: { + VolumeSize: 15, + VolumeType: 'gp3', + Throughput: 350, + }, + }, ], }, }); }); + test.each([124, 1001])('throws if throughput is set less than 125 or more than 1000', (throughput) => { + expect(() => { + new LaunchTemplate(stack, 'LaunchTemplate', { + blockDevices: [{ + deviceName: 'ebs', + volume: BlockDeviceVolume.ebs(15, { + volumeType: EbsDeviceVolumeType.GP3, + throughput, + }), + }], + }); + }).toThrow(/'throughput' must be between 125 and 1000, got/); + }); + test('throws if throughput is not an integer', () => { + expect(() => { + new LaunchTemplate(stack, 'LaunchTemplate', { + blockDevices: [{ + deviceName: 'ebs', + volume: BlockDeviceVolume.ebs(15, { + volumeType: EbsDeviceVolumeType.GP3, + throughput: 234.56, + }), + }], + }); + }).toThrow("'throughput' must be an integer, got: 234.56."); + }); + test.each([ + ...Object.values(EbsDeviceVolumeType).filter((v) => v !== 'gp3'), + ])('throws if throughput is set on any volume type other than GP3', (volumeType) => { + expect(() => { + new LaunchTemplate(stack, 'LaunchTemplate', { + blockDevices: [{ + deviceName: 'ebs', + volume: BlockDeviceVolume.ebs(15, { + volumeType: volumeType, + throughput: 150, + }), + }], + }); + }).toThrow(/'throughput' requires 'volumeType': gp3, got/); + }); + test('throws if throughput / iops ratio is greater than 0.25', () => { + expect(() => { + new LaunchTemplate(stack, 'LaunchTemplate', { + blockDevices: [{ + deviceName: 'ebs', + volume: BlockDeviceVolume.ebs(15, { + volumeType: EbsDeviceVolumeType.GP3, + throughput: 751, + iops: 3000, + }), + }], + }); + }).toThrow('Throughput (MiBps) to iops ratio of 0.25033333333333335 is too high; maximum is 0.25 MiBps per iops'); + }); test('Given instance profile', () => { // GIVEN From 39492e967f511de12524c2600c2108f3ec4c7493 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Fri, 30 Aug 2024 05:20:43 +0900 Subject: [PATCH 3/3] feat(codebuild): support three arm-based compute types, Medium, X-Large and 2X-Large (#31214) ### Issue # (if applicable) Closes #30869. ### Reason for this change Because three new arm-based compute types have become supported due to an update. Announcement: [AWS CodeBuild now supports three new Arm-based compute types ](https://aws.amazon.com/about-aws/whats-new/2024/08/aws-codebuild-three-arm-based-compute-types/) ### Description of changes Modify the validate method to allow Medium, X-Large, and 2X-Large as Arm-based compute types. ### Description of how you validated changes Modify unit tests and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../cdk.out | 1 + .../codebuild-project-arm.assets.json | 19 + .../codebuild-project-arm.template.json | 497 ++++++++++++ .../integ.json | 12 + ...efaultTestDeployAssert4EE92337.assets.json | 19 + ...aultTestDeployAssert4EE92337.template.json | 36 + .../manifest.json | 161 ++++ .../tree.json | 746 ++++++++++++++++++ .../test/integ.project-linux-arm.ts | 48 ++ .../lib/linux-arm-build-image.ts | 12 +- .../aws-codebuild/test/codebuild.test.ts | 75 +- .../test/linux-arm-build-image.test.ts | 189 +++-- 12 files changed, 1729 insertions(+), 86 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/cdk.out new file mode 100644 index 0000000000000..bd5311dc372de --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.5"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.assets.json new file mode 100644 index 0000000000000..15d66e1bb38f4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.5", + "files": { + "fb14db2f3f849c96db420afc9fd158b99550fa4ffa602209cd78e471a282fc4a": { + "source": { + "path": "codebuild-project-arm.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "fb14db2f3f849c96db420afc9fd158b99550fa4ffa602209cd78e471a282fc4a.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.template.json new file mode 100644 index 0000000000000..a902bdb9a33ce --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/codebuild-project-arm.template.json @@ -0,0 +1,497 @@ +{ + "Resources": { + "MyProjectMediumRole1F3769C8": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "MyProjectMediumRoleDefaultPolicy08D66D98": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectMediumE40D9677" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectMediumE40D9677" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectMediumE40D9677" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "MyProjectMediumRoleDefaultPolicy08D66D98", + "Roles": [ + { + "Ref": "MyProjectMediumRole1F3769C8" + } + ] + } + }, + "MyProjectMediumE40D9677": { + "Type": "AWS::CodeBuild::Project", + "Properties": { + "Artifacts": { + "Type": "NO_ARTIFACTS" + }, + "Cache": { + "Type": "NO_CACHE" + }, + "EncryptionKey": "alias/aws/s3", + "Environment": { + "ComputeType": "BUILD_GENERAL1_MEDIUM", + "Image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "ImagePullCredentialsType": "CODEBUILD", + "PrivilegedMode": false, + "Type": "ARM_CONTAINER" + }, + "ServiceRole": { + "Fn::GetAtt": [ + "MyProjectMediumRole1F3769C8", + "Arn" + ] + }, + "Source": { + "BuildSpec": "{\n \"version\": \"0.2\"\n}", + "Type": "NO_SOURCE" + } + } + }, + "MyProjectXLargeRoleC17867F7": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "MyProjectXLargeRoleDefaultPolicyACC3F91E": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectXLarge21A68AC6" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectXLarge21A68AC6" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectXLarge21A68AC6" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "MyProjectXLargeRoleDefaultPolicyACC3F91E", + "Roles": [ + { + "Ref": "MyProjectXLargeRoleC17867F7" + } + ] + } + }, + "MyProjectXLarge21A68AC6": { + "Type": "AWS::CodeBuild::Project", + "Properties": { + "Artifacts": { + "Type": "NO_ARTIFACTS" + }, + "Cache": { + "Type": "NO_CACHE" + }, + "EncryptionKey": "alias/aws/s3", + "Environment": { + "ComputeType": "BUILD_GENERAL1_XLARGE", + "Image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "ImagePullCredentialsType": "CODEBUILD", + "PrivilegedMode": false, + "Type": "ARM_CONTAINER" + }, + "ServiceRole": { + "Fn::GetAtt": [ + "MyProjectXLargeRoleC17867F7", + "Arn" + ] + }, + "Source": { + "BuildSpec": "{\n \"version\": \"0.2\"\n}", + "Type": "NO_SOURCE" + } + } + }, + "MyProjectX2LargeRole65F64577": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "MyProjectX2LargeRoleDefaultPolicy241428C8": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectX2Large715B77CC" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectX2Large715B77CC" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectX2Large715B77CC" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "MyProjectX2LargeRoleDefaultPolicy241428C8", + "Roles": [ + { + "Ref": "MyProjectX2LargeRole65F64577" + } + ] + } + }, + "MyProjectX2Large715B77CC": { + "Type": "AWS::CodeBuild::Project", + "Properties": { + "Artifacts": { + "Type": "NO_ARTIFACTS" + }, + "Cache": { + "Type": "NO_CACHE" + }, + "EncryptionKey": "alias/aws/s3", + "Environment": { + "ComputeType": "BUILD_GENERAL1_2XLARGE", + "Image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "ImagePullCredentialsType": "CODEBUILD", + "PrivilegedMode": false, + "Type": "ARM_CONTAINER" + }, + "ServiceRole": { + "Fn::GetAtt": [ + "MyProjectX2LargeRole65F64577", + "Arn" + ] + }, + "Source": { + "BuildSpec": "{\n \"version\": \"0.2\"\n}", + "Type": "NO_SOURCE" + } + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integ.json new file mode 100644 index 0000000000000..1b19409d332b6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.5", + "testCases": { + "integ-test-codebuild-project-arm/DefaultTest": { + "stacks": [ + "codebuild-project-arm" + ], + "assertionStack": "integ-test-codebuild-project-arm/DefaultTest/DeployAssert", + "assertionStackName": "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets.json new file mode 100644 index 0000000000000..f367aa992702d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.5", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/manifest.json new file mode 100644 index 0000000000000..9a9ed7d53e31d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/manifest.json @@ -0,0 +1,161 @@ +{ + "version": "36.0.5", + "artifacts": { + "codebuild-project-arm.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "codebuild-project-arm.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "codebuild-project-arm": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "codebuild-project-arm.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fb14db2f3f849c96db420afc9fd158b99550fa4ffa602209cd78e471a282fc4a.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "codebuild-project-arm.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "codebuild-project-arm.assets" + ], + "metadata": { + "/codebuild-project-arm/MyProjectMedium/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectMediumRole1F3769C8" + } + ], + "/codebuild-project-arm/MyProjectMedium/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectMediumRoleDefaultPolicy08D66D98" + } + ], + "/codebuild-project-arm/MyProjectMedium/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectMediumE40D9677" + } + ], + "/codebuild-project-arm/MyProjectXLarge/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectXLargeRoleC17867F7" + } + ], + "/codebuild-project-arm/MyProjectXLarge/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectXLargeRoleDefaultPolicyACC3F91E" + } + ], + "/codebuild-project-arm/MyProjectXLarge/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectXLarge21A68AC6" + } + ], + "/codebuild-project-arm/MyProjectX2Large/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectX2LargeRole65F64577" + } + ], + "/codebuild-project-arm/MyProjectX2Large/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectX2LargeRoleDefaultPolicy241428C8" + } + ], + "/codebuild-project-arm/MyProjectX2Large/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyProjectX2Large715B77CC" + } + ], + "/codebuild-project-arm/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/codebuild-project-arm/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "codebuild-project-arm" + }, + "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "integtestcodebuildprojectarmDefaultTestDeployAssert4EE92337.assets" + ], + "metadata": { + "/integ-test-codebuild-project-arm/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-test-codebuild-project-arm/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-test-codebuild-project-arm/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/tree.json new file mode 100644 index 0000000000000..a3bb52be1cc6d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.js.snapshot/tree.json @@ -0,0 +1,746 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "codebuild-project-arm": { + "id": "codebuild-project-arm", + "path": "codebuild-project-arm", + "children": { + "MyProjectMedium": { + "id": "MyProjectMedium", + "path": "codebuild-project-arm/MyProjectMedium", + "children": { + "Role": { + "id": "Role", + "path": "codebuild-project-arm/MyProjectMedium/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "codebuild-project-arm/MyProjectMedium/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectMedium/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "codebuild-project-arm/MyProjectMedium/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectMedium/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectMediumE40D9677" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectMediumE40D9677" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectMediumE40D9677" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "MyProjectMediumRoleDefaultPolicy08D66D98", + "roles": [ + { + "Ref": "MyProjectMediumRole1F3769C8" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectMedium/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CodeBuild::Project", + "aws:cdk:cloudformation:props": { + "artifacts": { + "type": "NO_ARTIFACTS" + }, + "cache": { + "type": "NO_CACHE" + }, + "encryptionKey": "alias/aws/s3", + "environment": { + "type": "ARM_CONTAINER", + "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "imagePullCredentialsType": "CODEBUILD", + "privilegedMode": false, + "computeType": "BUILD_GENERAL1_MEDIUM" + }, + "serviceRole": { + "Fn::GetAtt": [ + "MyProjectMediumRole1F3769C8", + "Arn" + ] + }, + "source": { + "type": "NO_SOURCE", + "buildSpec": "{\n \"version\": \"0.2\"\n}" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.CfnProject", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.Project", + "version": "0.0.0" + } + }, + "MyProjectXLarge": { + "id": "MyProjectXLarge", + "path": "codebuild-project-arm/MyProjectXLarge", + "children": { + "Role": { + "id": "Role", + "path": "codebuild-project-arm/MyProjectXLarge/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "codebuild-project-arm/MyProjectXLarge/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectXLarge/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "codebuild-project-arm/MyProjectXLarge/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectXLarge/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectXLarge21A68AC6" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectXLarge21A68AC6" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectXLarge21A68AC6" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "MyProjectXLargeRoleDefaultPolicyACC3F91E", + "roles": [ + { + "Ref": "MyProjectXLargeRoleC17867F7" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectXLarge/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CodeBuild::Project", + "aws:cdk:cloudformation:props": { + "artifacts": { + "type": "NO_ARTIFACTS" + }, + "cache": { + "type": "NO_CACHE" + }, + "encryptionKey": "alias/aws/s3", + "environment": { + "type": "ARM_CONTAINER", + "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "imagePullCredentialsType": "CODEBUILD", + "privilegedMode": false, + "computeType": "BUILD_GENERAL1_XLARGE" + }, + "serviceRole": { + "Fn::GetAtt": [ + "MyProjectXLargeRoleC17867F7", + "Arn" + ] + }, + "source": { + "type": "NO_SOURCE", + "buildSpec": "{\n \"version\": \"0.2\"\n}" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.CfnProject", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.Project", + "version": "0.0.0" + } + }, + "MyProjectX2Large": { + "id": "MyProjectX2Large", + "path": "codebuild-project-arm/MyProjectX2Large", + "children": { + "Role": { + "id": "Role", + "path": "codebuild-project-arm/MyProjectX2Large/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "codebuild-project-arm/MyProjectX2Large/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectX2Large/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "codebuild-project-arm/MyProjectX2Large/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectX2Large/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectX2Large715B77CC" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "MyProjectX2Large715B77CC" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "MyProjectX2Large715B77CC" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "MyProjectX2LargeRoleDefaultPolicy241428C8", + "roles": [ + { + "Ref": "MyProjectX2LargeRole65F64577" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "codebuild-project-arm/MyProjectX2Large/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CodeBuild::Project", + "aws:cdk:cloudformation:props": { + "artifacts": { + "type": "NO_ARTIFACTS" + }, + "cache": { + "type": "NO_CACHE" + }, + "encryptionKey": "alias/aws/s3", + "environment": { + "type": "ARM_CONTAINER", + "image": "aws/codebuild/amazonlinux2-aarch64-standard:3.0", + "imagePullCredentialsType": "CODEBUILD", + "privilegedMode": false, + "computeType": "BUILD_GENERAL1_2XLARGE" + }, + "serviceRole": { + "Fn::GetAtt": [ + "MyProjectX2LargeRole65F64577", + "Arn" + ] + }, + "source": { + "type": "NO_SOURCE", + "buildSpec": "{\n \"version\": \"0.2\"\n}" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.CfnProject", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.Project", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "codebuild-project-arm/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "codebuild-project-arm/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "integ-test-codebuild-project-arm": { + "id": "integ-test-codebuild-project-arm", + "path": "integ-test-codebuild-project-arm", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "integ-test-codebuild-project-arm/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "integ-test-codebuild-project-arm/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "integ-test-codebuild-project-arm/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-test-codebuild-project-arm/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-test-codebuild-project-arm/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.ts new file mode 100644 index 0000000000000..bf40ca6e8fac8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-codebuild/test/integ.project-linux-arm.ts @@ -0,0 +1,48 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import { BuildSpec, ComputeType, LinuxBuildImage, Project } from 'aws-cdk-lib/aws-codebuild'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +class AmazonLinuxArmTestStack extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + + new Project(this, 'MyProjectMedium', { + buildSpec: BuildSpec.fromObject({ + version: '0.2', + }), + environment: { + buildImage: LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + computeType: ComputeType.MEDIUM, + }, + }); + + new Project(this, 'MyProjectXLarge', { + buildSpec: BuildSpec.fromObject({ + version: '0.2', + }), + environment: { + buildImage: LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + computeType: ComputeType.X_LARGE, + }, + }); + + new Project(this, 'MyProjectX2Large', { + buildSpec: BuildSpec.fromObject({ + version: '0.2', + }), + environment: { + buildImage: LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + computeType: ComputeType.X2_LARGE, + }, + }); + } +} + +const app = new App(); + +const codebuildArm = new AmazonLinuxArmTestStack(app, 'codebuild-project-arm'); + +new IntegTest(app, 'integ-test-codebuild-project-arm', { + testCases: [codebuildArm], +}); diff --git a/packages/aws-cdk-lib/aws-codebuild/lib/linux-arm-build-image.ts b/packages/aws-cdk-lib/aws-codebuild/lib/linux-arm-build-image.ts index 3d32d529cd3ec..7d6e507d152e2 100644 --- a/packages/aws-cdk-lib/aws-codebuild/lib/linux-arm-build-image.ts +++ b/packages/aws-cdk-lib/aws-codebuild/lib/linux-arm-build-image.ts @@ -2,7 +2,7 @@ import { BuildSpec } from './build-spec'; import { ComputeType } from './compute-type'; import { EnvironmentType } from './environment-type'; import { runScriptLinuxBuildSpec } from './private/run-script-linux-build-spec'; -import { BuildEnvironment, IBuildImage, ImagePullPrincipalType, DockerImageOptions } from './project'; +import { BuildEnvironment, IBuildImage, ImagePullPrincipalType, DockerImageOptions, isLambdaComputeType } from './project'; import * as ecr from '../../aws-ecr'; import * as secretsmanager from '../../aws-secretsmanager'; @@ -103,17 +103,13 @@ export class LinuxArmBuildImage implements IBuildImage { } /** - * Validates by checking the BuildEnvironment computeType as aarch64 images only support ComputeType.SMALL and - * ComputeType.LARGE + * Validates by checking the BuildEnvironments' images are not Lambda ComputeTypes * @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`); + if (buildEnvironment.computeType && isLambdaComputeType(buildEnvironment.computeType)) { + ret.push(`ARM images do not support Lambda ComputeTypes, got ${buildEnvironment.computeType}`); } return ret; } diff --git a/packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts b/packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts index 3eb3ac3fe6894..e0923a70b1b3b 100644 --- a/packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts +++ b/packages/aws-cdk-lib/aws-codebuild/test/codebuild.test.ts @@ -1751,12 +1751,12 @@ describe('Linux x86-64 Image', () => { }); describe('ARM image', () => { - describe('AMAZON_LINUX_2_ARM', () => { + describe('AMAZON_LINUX_2_ARM_3', () => { test('has type ARM_CONTAINER and default ComputeType LARGE', () => { const stack = new cdk.Stack(); new codebuild.PipelineProject(stack, 'Project', { environment: { - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, }, }); @@ -1773,7 +1773,7 @@ describe('ARM image', () => { new codebuild.PipelineProject(stack, 'Project', { environment: { computeType: codebuild.ComputeType.SMALL, - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, }, }); @@ -1785,17 +1785,22 @@ describe('ARM image', () => { }); }); - test('cannot be used in conjunction with ComputeType MEDIUM', () => { + test('can be used with ComputeType MEDIUM', () => { const stack = new cdk.Stack(); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, - computeType: codebuild.ComputeType.MEDIUM, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + computeType: codebuild.ComputeType.MEDIUM, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + 'Environment': { + 'Type': 'ARM_CONTAINER', + 'ComputeType': 'BUILD_GENERAL1_MEDIUM', + }, + }); }); test('can be used with ComputeType LARGE', () => { @@ -1803,7 +1808,7 @@ describe('ARM image', () => { new codebuild.PipelineProject(stack, 'Project', { environment: { computeType: codebuild.ComputeType.LARGE, - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, }, }); @@ -1815,17 +1820,39 @@ describe('ARM image', () => { }); }); - test('cannot be used in conjunction with ComputeType X2_LARGE', () => { + test('can be used with ComputeType X_LARGE', () => { const stack = new cdk.Stack(); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + computeType: codebuild.ComputeType.X_LARGE, + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + }, + }); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, - computeType: codebuild.ComputeType.X2_LARGE, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/); + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + 'Environment': { + 'Type': 'ARM_CONTAINER', + 'ComputeType': 'BUILD_GENERAL1_XLARGE', + }, + }); + }); + + test('can be used with ComputeType X2_LARGE', () => { + const stack = new cdk.Stack(); + + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, + computeType: codebuild.ComputeType.X2_LARGE, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + 'Environment': { + 'Type': 'ARM_CONTAINER', + 'ComputeType': 'BUILD_GENERAL1_2XLARGE', + }, + }); }); test('cannot be used in conjunction with ComputeType LAMBDA_1GB', () => { @@ -1834,11 +1861,11 @@ describe('ARM image', () => { expect(() => { new codebuild.PipelineProject(stack, 'Project', { environment: { - buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM, + buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2_ARM_3, computeType: codebuild.ComputeType.LAMBDA_1GB, }, }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_LAMBDA_1GB' was given/); + }).toThrow('Invalid CodeBuild environment: ARM images do not support Lambda ComputeTypes, got BUILD_LAMBDA_1GB'); }); }); }); diff --git a/packages/aws-cdk-lib/aws-codebuild/test/linux-arm-build-image.test.ts b/packages/aws-cdk-lib/aws-codebuild/test/linux-arm-build-image.test.ts index 13c09bd069214..5653bb0ce1f95 100644 --- a/packages/aws-cdk-lib/aws-codebuild/test/linux-arm-build-image.test.ts +++ b/packages/aws-cdk-lib/aws-codebuild/test/linux-arm-build-image.test.ts @@ -38,17 +38,22 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType MEDIUM', () => { + test('can be used with ComputeType MEDIUM', () => { const stack = new cdk.Stack(); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0, - computeType: codebuild.ComputeType.MEDIUM, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0, + computeType: codebuild.ComputeType.MEDIUM, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_MEDIUM', + }, + }); }); test('can be used with ComputeType LARGE', () => { @@ -68,17 +73,39 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType X2_LARGE', () => { + test('can be used with ComputeType X_LARGE', () => { const stack = new cdk.Stack(); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + computeType: codebuild.ComputeType.X_LARGE, + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0, + }, + }); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0, - computeType: codebuild.ComputeType.X2_LARGE, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/); + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_XLARGE', + }, + }); + }); + + test('can be used with ComputeType X2_LARGE', () => { + const stack = new cdk.Stack(); + + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0, + computeType: codebuild.ComputeType.X2_LARGE, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_2XLARGE', + }, + }); }); }); @@ -116,17 +143,22 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType MEDIUM', () => { + test('can be used with ComputeType MEDIUM', () => { const stack = new cdk.Stack(); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0, - computeType: codebuild.ComputeType.MEDIUM, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0, + computeType: codebuild.ComputeType.MEDIUM, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_MEDIUM', + }, + }); }); test('can be used with ComputeType LARGE', () => { @@ -146,17 +178,39 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType X2_LARGE', () => { + test('can be used with ComputeType X_LARGE', () => { const stack = new cdk.Stack(); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + computeType: codebuild.ComputeType.X_LARGE, + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0, + }, + }); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0, - computeType: codebuild.ComputeType.X2_LARGE, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/); + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_XLARGE', + }, + }); + }); + + test('can be used with ComputeType X2_LARGE', () => { + const stack = new cdk.Stack(); + + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0, + computeType: codebuild.ComputeType.X2_LARGE, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_2XLARGE', + }, + }); }); }); @@ -194,17 +248,22 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType MEDIUM', () => { + test('can be used with ComputeType MEDIUM', () => { const stack = new cdk.Stack(); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0, - computeType: codebuild.ComputeType.MEDIUM, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_MEDIUM' was given/); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0, + computeType: codebuild.ComputeType.MEDIUM, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_MEDIUM', + }, + }); }); test('can be used with ComputeType LARGE', () => { @@ -224,17 +283,39 @@ describe('Linux ARM build image', () => { }); }); - test('cannot be used in conjunction with ComputeType X2_LARGE', () => { + test('can be used with ComputeType X_LARGE', () => { const stack = new cdk.Stack(); + new codebuild.PipelineProject(stack, 'Project', { + environment: { + computeType: codebuild.ComputeType.X_LARGE, + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0, + }, + }); - expect(() => { - new codebuild.PipelineProject(stack, 'Project', { - environment: { - buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0, - computeType: codebuild.ComputeType.X2_LARGE, - }, - }); - }).toThrow(/ARM images only support ComputeTypes 'BUILD_GENERAL1_SMALL' and 'BUILD_GENERAL1_LARGE' - 'BUILD_GENERAL1_2XLARGE' was given/); + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_XLARGE', + }, + }); + }); + + test('can be used with ComputeType X2_LARGE', () => { + const stack = new cdk.Stack(); + + new codebuild.PipelineProject(stack, 'Project', { + environment: { + buildImage: codebuild.LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0, + computeType: codebuild.ComputeType.X2_LARGE, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::CodeBuild::Project', { + Environment: { + Type: 'ARM_CONTAINER', + ComputeType: 'BUILD_GENERAL1_2XLARGE', + }, + }); }); });