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 regex for ebs optimized setting #791

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/barcelona/network/autoscaling_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/barcelona/network/network_stack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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