Skip to content

Commit fb9f559

Browse files
fix(batch): computeEnvironmentName is not set in FargateComputeEnvironment (#25944)
computeEnvironmentName property was missing in FargateComputeEnvironment due to which ComputeEnvironmentName property set on the resulting AWS::Batch::ComputeEnvironment resource in the outputted CloudFormation. Updated managed-compute-environment to reflect the fix made in FargateComputeEnvironment. Closes #25794.
1 parent 79c58ed commit fb9f559

9 files changed

+43
-14
lines changed

packages/@aws-cdk/aws-batch-alpha/lib/managed-compute-environment.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ export class FargateComputeEnvironment extends ManagedComputeEnvironmentBase imp
10881088
const { subnetIds } = props.vpc.selectSubnets(props.vpcSubnets);
10891089
const resource = new CfnComputeEnvironment(this, 'Resource', {
10901090
...baseManagedResourceProperties(this, subnetIds),
1091+
computeEnvironmentName: props.computeEnvironmentName,
10911092
computeResources: {
10921093
...baseManagedResourceProperties(this, subnetIds).computeResources as CfnComputeEnvironment.ComputeResourcesProperty,
10931094
type: this.spot ? 'FARGATE_SPOT' : 'FARGATE',

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/BatchManagedComputeEnvironmentTestDefaultTestDeployAssertD4528F80.assets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"files": {
44
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
55
"source": {

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/batch-stack.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"files": {
4-
"6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0": {
4+
"81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2": {
55
"source": {
66
"path": "batch-stack.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0.json",
12+
"objectKey": "81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/batch-stack.template.json

+1
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@
457457
"Type": "AWS::Batch::ComputeEnvironment",
458458
"Properties": {
459459
"Type": "managed",
460+
"ComputeEnvironmentName": "maxPropsFargateCE",
460461
"ComputeResources": {
461462
"MaxvCpus": 512,
462463
"SecurityGroupIds": [
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"31.0.0"}
1+
{"version":"32.0.0"}

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/integ.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"testCases": {
44
"BatchManagedComputeEnvironmentTest/DefaultTest": {
55
"stacks": [

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/manifest.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "31.0.0",
2+
"version": "32.0.0",
33
"artifacts": {
44
"batch-stack.assets": {
55
"type": "cdk:asset-manifest",
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -192,7 +192,10 @@
192192
"/batch-stack/maximalPropsFargate/Resource": [
193193
{
194194
"type": "aws:cdk:logicalId",
195-
"data": "maximalPropsFargate2D7D8138"
195+
"data": "maximalPropsFargate2D7D8138",
196+
"trace": [
197+
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
198+
]
196199
}
197200
],
198201
"/batch-stack/minimalPropsEc2/SecurityGroup/Resource": [
@@ -312,10 +315,7 @@
312315
"/batch-stack/taggedCE/Resource": [
313316
{
314317
"type": "aws:cdk:logicalId",
315-
"data": "taggedCE5029E6F8",
316-
"trace": [
317-
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
318-
]
318+
"data": "taggedCE5029E6F8"
319319
}
320320
],
321321
"/batch-stack/BootstrapVersion": [

packages/@aws-cdk/aws-batch-alpha/test/integ.managed-compute-environment.js.snapshot/tree.json

+1
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@
778778
"aws:cdk:cloudformation:type": "AWS::Batch::ComputeEnvironment",
779779
"aws:cdk:cloudformation:props": {
780780
"type": "managed",
781+
"computeEnvironmentName": "maxPropsFargateCE",
781782
"computeResources": {
782783
"maxvCpus": 512,
783784
"type": "FARGATE_SPOT",

packages/@aws-cdk/aws-batch-alpha/test/managed-compute-environment.test.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ArnPrincipal, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
55
import { Stack, Duration, Tags } from 'aws-cdk-lib';
66
import { capitalizePropertyNames } from './utils';
77
import * as batch from '../lib';
8-
import { AllocationStrategy, ManagedEc2EcsComputeEnvironment, ManagedEc2EcsComputeEnvironmentProps, ManagedEc2EksComputeEnvironment, ManagedEc2EksComputeEnvironmentProps } from '../lib';
8+
import { AllocationStrategy, ManagedEc2EcsComputeEnvironment, ManagedEc2EcsComputeEnvironmentProps, ManagedEc2EksComputeEnvironment, ManagedEc2EksComputeEnvironmentProps, FargateComputeEnvironment } from '../lib';
99
import { CfnComputeEnvironmentProps } from 'aws-cdk-lib/aws-batch';
1010

1111
const defaultExpectedEcsProps: CfnComputeEnvironmentProps = {
@@ -910,3 +910,29 @@ describe('ManagedEc2EksComputeEnvironment', () => {
910910
});
911911
});
912912
});
913+
914+
describe('FargateComputeEnvironment', () => {
915+
beforeEach(() => {
916+
stack = new Stack();
917+
vpc = new ec2.Vpc(stack, 'vpc');
918+
});
919+
920+
test('respects name', () => {
921+
// WHEN
922+
new FargateComputeEnvironment(stack, 'maximalPropsFargate', {
923+
vpc,
924+
maxvCpus: 512,
925+
computeEnvironmentName: 'maxPropsFargateCE',
926+
replaceComputeEnvironment: true,
927+
spot: true,
928+
terminateOnUpdate: true,
929+
updateTimeout: Duration.minutes(30),
930+
updateToLatestImageVersion: false,
931+
});
932+
933+
// THEN
934+
Template.fromStack(stack).hasResourceProperties('AWS::Batch::ComputeEnvironment', {
935+
ComputeEnvironmentName: 'maxPropsFargateCE',
936+
});
937+
});
938+
});

0 commit comments

Comments
 (0)