From 7b6b091a42fddb7d0baac708b711b805c1292c2e Mon Sep 17 00:00:00 2001 From: Frank Mata Date: Mon, 24 Jul 2023 15:13:29 +0900 Subject: [PATCH 1/3] Fix regex for ebs optimized --- lib/barcelona/network/autoscaling_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/barcelona/network/autoscaling_builder.rb b/lib/barcelona/network/autoscaling_builder.rb index 885ecb40..d4c3eb7b 100644 --- a/lib/barcelona/network/autoscaling_builder.rb +++ b/lib/barcelona/network/autoscaling_builder.rb @@ -26,7 +26,7 @@ class AutoscalingBuilder < CloudFormation::Builder def ebs_optimized_by_default? # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html - !!(instance_type =~ /\A(a1|c4|c5.?|d2|f1|g3.?|h1|i3|m4|m5.?|m6()?|p2|p3(dn)?|r4|r5.?|t3|u-.*|x1.?|z1d)\..*\z/) + !!(instance_type =~ /\A(a1|c4|c5.?|d2|f1|g3.?|h1|i3|m4|m5.?|m6.+||p2|p3(dn)?|r4|r5.?|t3|u-.*|x1.?|z1d)\..*\z/) end def build_resources From 19659c6dc52dc657ba49c42fd15efae99fdd990a Mon Sep 17 00:00:00 2001 From: Frank Mata Date: Mon, 24 Jul 2023 15:22:23 +0900 Subject: [PATCH 2/3] Update autoscaling_builder.rb --- lib/barcelona/network/autoscaling_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/barcelona/network/autoscaling_builder.rb b/lib/barcelona/network/autoscaling_builder.rb index d4c3eb7b..3f1054aa 100644 --- a/lib/barcelona/network/autoscaling_builder.rb +++ b/lib/barcelona/network/autoscaling_builder.rb @@ -26,7 +26,7 @@ class AutoscalingBuilder < CloudFormation::Builder def ebs_optimized_by_default? # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html - !!(instance_type =~ /\A(a1|c4|c5.?|d2|f1|g3.?|h1|i3|m4|m5.?|m6.+||p2|p3(dn)?|r4|r5.?|t3|u-.*|x1.?|z1d)\..*\z/) + !!(instance_type =~ /\A(a1|c4|c5.?|d2|f1|g3.?|h1|i3|m4|m5.?|m6.+|p2|p3(dn)?|r4|r5.?|t3|u-.*|x1.?|z1d)\..*\z/) end def build_resources From 4cf59a7423c9383e0e8c6a8fde17afe9034cc967 Mon Sep 17 00:00:00 2001 From: Frank Mata Date: Mon, 24 Jul 2023 16:13:55 +0900 Subject: [PATCH 3/3] Add test for ebs optimized check --- .../lib/barcelona/network/network_stack_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/lib/barcelona/network/network_stack_spec.rb b/spec/lib/barcelona/network/network_stack_spec.rb index 607f0024..3d1c3a09 100644 --- a/spec/lib/barcelona/network/network_stack_spec.rb +++ b/spec/lib/barcelona/network/network_stack_spec.rb @@ -1070,4 +1070,21 @@ expect(generated["Resources"]["RouteNATForRouteTableTrusted2"]).to be_present end end + + it "m6i.large instance type is ebs optimized" do + district.nat_type = nil + district.cluster_instance_type = "m6i.large" + stack = described_class.new(district) + generated = JSON.load(stack.target!) + expect(generated["Resources"]["ContainerInstanceLaunchConfiguration"]["Properties"]["EbsOptimized"]).to eq true + end + + it "m1.large instance type is not ebs optimized by default" do + district.nat_type = nil + district.cluster_instance_type = "m1.large" + stack = described_class.new(district) + generated = JSON.load(stack.target!) + expect(generated["Resources"]["ContainerInstanceLaunchConfiguration"]["Properties"]["EbsOptimized"]).to eq false + end + end