Skip to content

Commit 7e80cc9

Browse files
authored
fix(batch): remove default optimal for arm based instance types and add error checks (#31510)
### Issue # (if applicable) Closes #31148 ### Reason for this change When adding an arm-based instance, optimal instance is set by default which consists of an x86-based instance. This causes errors since arm and x86 instances can't be mixed together. ### Description of changes - useOptimalInstanceClasses is set to false for all arm-based instances - Throws error when trying to mix x86 and arm instances - Case 1: Instantiating the class - Case 2: addInstanceClass and addInstanceType functions - Warning useOptimalInstanceClasses is being set to false for arm-based instances ### Description of how you validated changes - Unit test where optimal doesn't get added for arm-based instances - Unit tests to display errors when instantiating the class - Unit tests to display errors when addInstanceClass and addInstanceType is adding mixed instances - Unit tests to display warning for arm based instances ### 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*
1 parent b20fd8e commit 7e80cc9

File tree

10 files changed

+492
-19
lines changed

10 files changed

+492
-19
lines changed

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+106
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,112 @@
986986
"UpdatePolicy": {}
987987
}
988988
},
989+
"noOptimalInstancesForARMSecurityGroup7157B016": {
990+
"Type": "AWS::EC2::SecurityGroup",
991+
"Properties": {
992+
"GroupDescription": "batch-stack/noOptimalInstancesForARM/SecurityGroup",
993+
"SecurityGroupEgress": [
994+
{
995+
"CidrIp": "0.0.0.0/0",
996+
"Description": "Allow all outbound traffic by default",
997+
"IpProtocol": "-1"
998+
}
999+
],
1000+
"VpcId": {
1001+
"Ref": "vpcA2121C38"
1002+
}
1003+
}
1004+
},
1005+
"noOptimalInstancesForARMInstanceProfileRole926AEEC5": {
1006+
"Type": "AWS::IAM::Role",
1007+
"Properties": {
1008+
"AssumeRolePolicyDocument": {
1009+
"Statement": [
1010+
{
1011+
"Action": "sts:AssumeRole",
1012+
"Effect": "Allow",
1013+
"Principal": {
1014+
"Service": "ec2.amazonaws.com"
1015+
}
1016+
}
1017+
],
1018+
"Version": "2012-10-17"
1019+
},
1020+
"ManagedPolicyArns": [
1021+
{
1022+
"Fn::Join": [
1023+
"",
1024+
[
1025+
"arn:",
1026+
{
1027+
"Ref": "AWS::Partition"
1028+
},
1029+
":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
1030+
]
1031+
]
1032+
}
1033+
]
1034+
}
1035+
},
1036+
"noOptimalInstancesForARMInstanceProfile37BE9D32": {
1037+
"Type": "AWS::IAM::InstanceProfile",
1038+
"Properties": {
1039+
"Roles": [
1040+
{
1041+
"Ref": "noOptimalInstancesForARMInstanceProfileRole926AEEC5"
1042+
}
1043+
]
1044+
}
1045+
},
1046+
"noOptimalInstancesForARMF146AA4D": {
1047+
"Type": "AWS::Batch::ComputeEnvironment",
1048+
"Properties": {
1049+
"ComputeResources": {
1050+
"AllocationStrategy": "BEST_FIT_PROGRESSIVE",
1051+
"Ec2Configuration": [
1052+
{
1053+
"ImageIdOverride": {
1054+
"Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter"
1055+
},
1056+
"ImageType": "ECS_AL2"
1057+
}
1058+
],
1059+
"InstanceRole": {
1060+
"Fn::GetAtt": [
1061+
"noOptimalInstancesForARMInstanceProfile37BE9D32",
1062+
"Arn"
1063+
]
1064+
},
1065+
"InstanceTypes": [
1066+
"a1.large",
1067+
"m6g"
1068+
],
1069+
"MaxvCpus": 256,
1070+
"MinvCpus": 0,
1071+
"SecurityGroupIds": [
1072+
{
1073+
"Fn::GetAtt": [
1074+
"noOptimalInstancesForARMSecurityGroup7157B016",
1075+
"GroupId"
1076+
]
1077+
}
1078+
],
1079+
"Subnets": [
1080+
{
1081+
"Ref": "vpcPrivateSubnet1Subnet934893E8"
1082+
},
1083+
{
1084+
"Ref": "vpcPrivateSubnet2Subnet7031C2BA"
1085+
}
1086+
],
1087+
"Type": "EC2"
1088+
},
1089+
"ReplaceComputeEnvironment": false,
1090+
"State": "ENABLED",
1091+
"Type": "managed",
1092+
"UpdatePolicy": {}
1093+
}
1094+
},
9891095
"taggedCESecurityGroup82CCF59F": {
9901096
"Type": "AWS::EC2::SecurityGroup",
9911097
"Properties": {

packages/@aws-cdk-testing/framework-integ/test/aws-batch/test/integ.managed-compute-environment.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+32-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+176
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)