Skip to content

Commit 75f5b3b

Browse files
fix(stepfunctions-tasks): migrate from deprecated batch properties (#19298)
fixes #18993 + update integ tests ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d91b2e2 commit 75f5b3b

11 files changed

+525
-433
lines changed

packages/@aws-cdk/aws-stepfunctions-tasks/lib/batch/submit-job.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,37 @@ export class BatchSubmitJob extends sfn.TaskStateBase {
291291
);
292292
}
293293

294-
let resources;
294+
let resources: Array<any> = [];
295295
if (containerOverrides.gpuCount) {
296-
resources = [
296+
resources.push(
297297
{
298298
Type: 'GPU',
299299
Value: `${containerOverrides.gpuCount}`,
300300
},
301-
];
301+
);
302+
}
303+
if (containerOverrides.memory) {
304+
resources.push(
305+
{
306+
Type: 'MEMORY',
307+
Value: `${containerOverrides.memory.toMebibytes()}`,
308+
},
309+
);
310+
}
311+
if (containerOverrides.vcpus) {
312+
resources.push(
313+
{
314+
Type: 'VCPU',
315+
Value: `${containerOverrides.vcpus}`,
316+
},
317+
);
302318
}
303319

304320
return {
305321
Command: containerOverrides.command,
306322
Environment: environment,
307323
InstanceType: containerOverrides.instanceType?.toString(),
308-
Memory: containerOverrides.memory?.toMebibytes(),
309-
ResourceRequirements: resources,
310-
Vcpus: containerOverrides.vcpus,
324+
ResourceRequirements: resources.length ? resources : undefined,
311325
};
312326
}
313327
}

packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-http-api.expected.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
"AutoDeploy": true
1818
}
1919
},
20+
"MyHttpApiANYDefaultIntegration5FAD8850": {
21+
"Type": "AWS::ApiGatewayV2::Integration",
22+
"Properties": {
23+
"ApiId": {
24+
"Ref": "MyHttpApi8AEAAC21"
25+
},
26+
"IntegrationType": "AWS_PROXY",
27+
"IntegrationUri": {
28+
"Fn::GetAtt": [
29+
"HelloHandler2E4FBA4D",
30+
"Arn"
31+
]
32+
},
33+
"PayloadFormatVersion": "2.0"
34+
}
35+
},
2036
"MyHttpApiANYDefaultIntegrationPermissionAB8301EF": {
2137
"Type": "AWS::Lambda::Permission",
2238
"Properties": {
@@ -54,22 +70,6 @@
5470
}
5571
}
5672
},
57-
"MyHttpApiANYDefaultIntegration5FAD8850": {
58-
"Type": "AWS::ApiGatewayV2::Integration",
59-
"Properties": {
60-
"ApiId": {
61-
"Ref": "MyHttpApi8AEAAC21"
62-
},
63-
"IntegrationType": "AWS_PROXY",
64-
"IntegrationUri": {
65-
"Fn::GetAtt": [
66-
"HelloHandler2E4FBA4D",
67-
"Arn"
68-
]
69-
},
70-
"PayloadFormatVersion": "2.0"
71-
}
72-
},
7373
"MyHttpApiANYC3543576": {
7474
"Type": "AWS::ApiGatewayV2::Route",
7575
"Properties": {

packages/@aws-cdk/aws-stepfunctions-tasks/test/apigateway/integ.call-rest-api.expected.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
},
7575
"StageName": "prod"
7676
},
77-
"DependsOn": ["MyRestApiAccount2FB6DB7A"]
77+
"DependsOn": [
78+
"MyRestApiAccount2FB6DB7A"
79+
]
7880
},
7981
"MyRestApiANYApiPermissionCallRestApiIntegMyRestApiB570839CANY0C27C1E3": {
8082
"Type": "AWS::Lambda::Permission",

packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/integ.run-batch-job.expected.json

+74-68
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@
9595
"vpcPublicSubnet1NATGateway9C16659E": {
9696
"Type": "AWS::EC2::NatGateway",
9797
"Properties": {
98+
"SubnetId": {
99+
"Ref": "vpcPublicSubnet1Subnet2E65531E"
100+
},
98101
"AllocationId": {
99102
"Fn::GetAtt": [
100103
"vpcPublicSubnet1EIPDA49DCBE",
101104
"AllocationId"
102105
]
103106
},
104-
"SubnetId": {
105-
"Ref": "vpcPublicSubnet1Subnet2E65531E"
106-
},
107107
"Tags": [
108108
{
109109
"Key": "Name",
@@ -192,15 +192,15 @@
192192
"vpcPublicSubnet2NATGateway9B8AE11A": {
193193
"Type": "AWS::EC2::NatGateway",
194194
"Properties": {
195+
"SubnetId": {
196+
"Ref": "vpcPublicSubnet2Subnet009B674F"
197+
},
195198
"AllocationId": {
196199
"Fn::GetAtt": [
197200
"vpcPublicSubnet2EIP9B3743B1",
198201
"AllocationId"
199202
]
200203
},
201-
"SubnetId": {
202-
"Ref": "vpcPublicSubnet2Subnet009B674F"
203-
},
204204
"Tags": [
205205
{
206206
"Key": "Name",
@@ -289,15 +289,15 @@
289289
"vpcPublicSubnet3NATGateway82F6CA9E": {
290290
"Type": "AWS::EC2::NatGateway",
291291
"Properties": {
292+
"SubnetId": {
293+
"Ref": "vpcPublicSubnet3Subnet11B92D7C"
294+
},
292295
"AllocationId": {
293296
"Fn::GetAtt": [
294297
"vpcPublicSubnet3EIP2C3B9D91",
295298
"AllocationId"
296299
]
297300
},
298-
"SubnetId": {
299-
"Ref": "vpcPublicSubnet3Subnet11B92D7C"
300-
},
301301
"Tags": [
302302
{
303303
"Key": "Name",
@@ -514,45 +514,20 @@
514514
}
515515
}
516516
},
517-
"ComputeEnvEcsInstanceRoleCFB290F9": {
518-
"Type": "AWS::IAM::Role",
517+
"ComputeEnvResourceSecurityGroupB84CF86B": {
518+
"Type": "AWS::EC2::SecurityGroup",
519519
"Properties": {
520-
"AssumeRolePolicyDocument": {
521-
"Statement": [
522-
{
523-
"Action": "sts:AssumeRole",
524-
"Effect": "Allow",
525-
"Principal": {
526-
"Service": {
527-
"Fn::Join": [
528-
"",
529-
[
530-
"ec2.",
531-
{
532-
"Ref": "AWS::URLSuffix"
533-
}
534-
]
535-
]
536-
}
537-
}
538-
}
539-
],
540-
"Version": "2012-10-17"
541-
},
542-
"ManagedPolicyArns": [
520+
"GroupDescription": "aws-stepfunctions-integ/ComputeEnv/Resource-Security-Group",
521+
"SecurityGroupEgress": [
543522
{
544-
"Fn::Join": [
545-
"",
546-
[
547-
"arn:",
548-
{
549-
"Ref": "AWS::Partition"
550-
},
551-
":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
552-
]
553-
]
523+
"CidrIp": "0.0.0.0/0",
524+
"Description": "Allow all outbound traffic by default",
525+
"IpProtocol": "-1"
554526
}
555-
]
527+
],
528+
"VpcId": {
529+
"Ref": "vpcA2121C38"
530+
}
556531
},
557532
"DependsOn": [
558533
"vpcIGWE57CBDCA",
@@ -590,12 +565,43 @@
590565
"vpcVPCGW7984C166"
591566
]
592567
},
593-
"ComputeEnvInstanceProfile81AFCCF2": {
594-
"Type": "AWS::IAM::InstanceProfile",
568+
"ComputeEnvEcsInstanceRoleCFB290F9": {
569+
"Type": "AWS::IAM::Role",
595570
"Properties": {
596-
"Roles": [
571+
"AssumeRolePolicyDocument": {
572+
"Statement": [
573+
{
574+
"Action": "sts:AssumeRole",
575+
"Effect": "Allow",
576+
"Principal": {
577+
"Service": {
578+
"Fn::Join": [
579+
"",
580+
[
581+
"ec2.",
582+
{
583+
"Ref": "AWS::URLSuffix"
584+
}
585+
]
586+
]
587+
}
588+
}
589+
}
590+
],
591+
"Version": "2012-10-17"
592+
},
593+
"ManagedPolicyArns": [
597594
{
598-
"Ref": "ComputeEnvEcsInstanceRoleCFB290F9"
595+
"Fn::Join": [
596+
"",
597+
[
598+
"arn:",
599+
{
600+
"Ref": "AWS::Partition"
601+
},
602+
":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
603+
]
604+
]
599605
}
600606
]
601607
},
@@ -635,20 +641,14 @@
635641
"vpcVPCGW7984C166"
636642
]
637643
},
638-
"ComputeEnvResourceSecurityGroupB84CF86B": {
639-
"Type": "AWS::EC2::SecurityGroup",
644+
"ComputeEnvInstanceProfile81AFCCF2": {
645+
"Type": "AWS::IAM::InstanceProfile",
640646
"Properties": {
641-
"GroupDescription": "aws-stepfunctions-integ/ComputeEnv/Resource-Security-Group",
642-
"SecurityGroupEgress": [
647+
"Roles": [
643648
{
644-
"CidrIp": "0.0.0.0/0",
645-
"Description": "Allow all outbound traffic by default",
646-
"IpProtocol": "-1"
649+
"Ref": "ComputeEnvEcsInstanceRoleCFB290F9"
647650
}
648-
],
649-
"VpcId": {
650-
"Ref": "vpcA2121C38"
651-
}
651+
]
652652
},
653653
"DependsOn": [
654654
"vpcIGWE57CBDCA",
@@ -755,12 +755,6 @@
755755
"ComputeEnv2C40ACC2": {
756756
"Type": "AWS::Batch::ComputeEnvironment",
757757
"Properties": {
758-
"ServiceRole": {
759-
"Fn::GetAtt": [
760-
"ComputeEnvResourceServiceInstanceRoleCF89E9E1",
761-
"Arn"
762-
]
763-
},
764758
"Type": "MANAGED",
765759
"ComputeResources": {
766760
"AllocationStrategy": "BEST_FIT",
@@ -796,6 +790,12 @@
796790
],
797791
"Type": "EC2"
798792
},
793+
"ServiceRole": {
794+
"Fn::GetAtt": [
795+
"ComputeEnvResourceServiceInstanceRoleCF89E9E1",
796+
"Arn"
797+
]
798+
},
799799
"State": "ENABLED"
800800
},
801801
"DependsOn": [
@@ -876,8 +876,14 @@
876876
"Privileged": false,
877877
"ReadonlyRootFilesystem": false,
878878
"ResourceRequirements": [
879-
{ "Type": "VCPU", "Value": "1" },
880-
{ "Type": "MEMORY", "Value": "4" }
879+
{
880+
"Type": "VCPU",
881+
"Value": "1"
882+
},
883+
{
884+
"Type": "MEMORY",
885+
"Value": "4"
886+
}
881887
]
882888
},
883889
"PlatformCapabilities": [

0 commit comments

Comments
 (0)