-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added validation to ec2 region names.
An argument error is raised if the region name is an availability zone. This should eliminate the unhelpful networking errors raised when failing to resolve the endpoint. Fixes #966
- Loading branch information
1 parent
42f772d
commit b84bfa1
Showing
5 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
aws-sdk-core/lib/aws-sdk-core/plugins/ec2_region_validation.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Aws | ||
module Plugins | ||
# @api private | ||
class EC2RegionValidation < Seahorse::Client::Plugin | ||
|
||
def after_initialize(client) | ||
if region = client.config.region | ||
if matches = region.match(/^(\w+-\w+-\d+)[a-z]$/) | ||
msg = ":region option must a region name, not an availability " | ||
msg << "zone name; try `#{matches[1]}' instead of `#{matches[0]}'" | ||
raise ArgumentError, msg | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters