Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(batch): computeEnvironmentName is not set in FargateComputeEnvironment #25944

Merged
merged 13 commits into from
Jun 12, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ export class FargateComputeEnvironment extends ManagedComputeEnvironmentBase imp
const { subnetIds } = props.vpc.selectSubnets(props.vpcSubnets);
const resource = new CfnComputeEnvironment(this, 'Resource', {
...baseManagedResourceProperties(this, subnetIds),
computeEnvironmentName: props.computeEnvironmentName,
computeResources: {
...baseManagedResourceProperties(this, subnetIds).computeResources as CfnComputeEnvironment.ComputeResourcesProperty,
type: this.spot ? 'FARGATE_SPOT' : 'FARGATE',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "31.0.0",
"version": "32.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "31.0.0",
"version": "32.0.0",
"files": {
"6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0": {
"81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2": {
"source": {
"path": "batch-stack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0.json",
"objectKey": "81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@
"Type": "AWS::Batch::ComputeEnvironment",
"Properties": {
"Type": "managed",
"ComputeEnvironmentName": "maxPropsFargateCE",
"ComputeResources": {
"MaxvCpus": 512,
"SecurityGroupIds": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"31.0.0"}
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "31.0.0",
"version": "32.0.0",
"testCases": {
"BatchManagedComputeEnvironmentTest/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "31.0.0",
"version": "32.0.0",
"artifacts": {
"batch-stack.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,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}/6ebdcdec29ca32bb55c4daa83140fbc6af6c8a2663beb1c1a833a3d4c6ee12c0.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/81f3134124cef368d56ccabda586dbcbef39a78089edd14c9d641cbcb4e0bad2.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -192,7 +192,10 @@
"/batch-stack/maximalPropsFargate/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "maximalPropsFargate2D7D8138"
"data": "maximalPropsFargate2D7D8138",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
}
],
"/batch-stack/minimalPropsEc2/SecurityGroup/Resource": [
Expand Down Expand Up @@ -312,10 +315,7 @@
"/batch-stack/taggedCE/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "taggedCE5029E6F8",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
"data": "taggedCE5029E6F8"
}
],
"/batch-stack/BootstrapVersion": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@
"aws:cdk:cloudformation:type": "AWS::Batch::ComputeEnvironment",
"aws:cdk:cloudformation:props": {
"type": "managed",
"computeEnvironmentName": "maxPropsFargateCE",
"computeResources": {
"maxvCpus": 512,
"type": "FARGATE_SPOT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ArnPrincipal, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
import { Stack, Duration, Tags } from 'aws-cdk-lib';
import { capitalizePropertyNames } from './utils';
import * as batch from '../lib';
import { AllocationStrategy, ManagedEc2EcsComputeEnvironment, ManagedEc2EcsComputeEnvironmentProps, ManagedEc2EksComputeEnvironment, ManagedEc2EksComputeEnvironmentProps } from '../lib';
import { AllocationStrategy, ManagedEc2EcsComputeEnvironment, ManagedEc2EcsComputeEnvironmentProps, ManagedEc2EksComputeEnvironment, ManagedEc2EksComputeEnvironmentProps, FargateComputeEnvironment } from '../lib';
import { CfnComputeEnvironmentProps } from 'aws-cdk-lib/aws-batch';

const defaultExpectedEcsProps: CfnComputeEnvironmentProps = {
Expand Down Expand Up @@ -910,3 +910,29 @@ describe('ManagedEc2EksComputeEnvironment', () => {
});
});
});

describe('FargateComputeEnvironment', () => {
beforeEach(() => {
stack = new Stack();
vpc = new ec2.Vpc(stack, 'vpc');
});

test('respects name', () => {
// WHEN
new FargateComputeEnvironment(stack, 'maximalPropsFargate', {
vpc,
maxvCpus: 512,
computeEnvironmentName: 'maxPropsFargateCE',
replaceComputeEnvironment: true,
spot: true,
terminateOnUpdate: true,
updateTimeout: Duration.minutes(30),
updateToLatestImageVersion: false,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Batch::ComputeEnvironment', {
ComputeEnvironmentName: 'maxPropsFargateCE',
});
});
});