Skip to content

Commit

Permalink
[Storage] Fix method used to get the AWS domain for FSx.
Browse files Browse the repository at this point in the history
In particular, now it does not need anymore to access the undefined
node attribute in US ISO regions.

Signed-off-by: Giacomo Marciani <mgiacomo@amazon.com>
  • Loading branch information
gmarciani committed Jun 12, 2024
1 parent e1b1a4e commit 7123b54
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cookbooks/aws-parallelcluster-environment/libraries/fsx.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
def aws_domain_for_fsx(region)
# DNS names have the default AWS domain (amazonaws.com) also in China and GovCloud.
region.start_with?("us-iso") ? aws_domain : CLASSIC_AWS_DOMAIN
if region.start_with?("us-iso-")
US_ISO_AWS_DOMAIN
elsif region.start_with?("us-isob-")
US_ISOB_AWS_DOMAIN
else
CLASSIC_AWS_DOMAIN
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

describe 'aws-parallelcluster-environment:libraries:aws_domain_for_fsx' do
shared_examples 'a valid aws_domain_for_fsx function' do |region, expected_aws_domain|
it 'returns the correct AWS domain' do
result = aws_domain_for_fsx(region)
expect(result).to eq(expected_aws_domain)
end
end

context 'when in US-ISO region' do
include_examples 'a valid aws_domain_for_fsx function', 'us-iso-WHATEVER', 'c2s.ic.gov'
end

context 'when in US-ISOB region' do
include_examples 'a valid aws_domain_for_fsx function', 'us-isob-', 'sc2s.sgov.gov'
end

context 'when in CN region' do
include_examples 'a valid aws_domain_for_fsx function', 'cn-WHATEVER', 'amazonaws.com'
end

context 'when in GovCloud region' do
include_examples 'a valid aws_domain_for_fsx function', 'us-gov-WHATEVER', 'amazonaws.com'
end

context 'when in whatever else region' do
include_examples 'a valid aws_domain_for_fsx function', 'WHATEVER-ELSE', 'amazonaws.com'
end
end

0 comments on commit 7123b54

Please sign in to comment.