Skip to content

Commit

Permalink
Merge #108
Browse files Browse the repository at this point in the history
108: Set region to nothing for Route53 endpoint when making service URL r=mattBrzezinski a=mattBrzezinski

**Resolves:** #107 

## Current Behaviour
Currently when making a request to `route53` the URL which we hit is `route53.us-east-1.amazonaws.com`, this is not a valid endpoint and results in a `DNSError` being thrown.

## Expected Behaviour
We currently special case one region less service `sdb`, I've made this into a list of strings and tacked in `route53` as well.

Now when you run the code example the request goes through successfully.

## Code Example
```julia
using AWSCore.Services: route53
route53("GET", "/2013-04-01/accountlimit/MAX_HEALTH_CHECKS_BY_OWNER")

# ERROR: DNSError: route53.us-east-1.amazonaws.com, unknown node or service (EAI_NONAME)
```

Co-authored-by: Matt Brzezinski <matt.brzezinski@invenia.ca>
  • Loading branch information
bors[bot] and mattBrzezinski committed Jan 29, 2020
2 parents 19a921f + f6522e6 commit 0da160a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ os:
- osx
julia:
- 1.0
- 1.1
- 1.3
- nightly
matrix:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AWSCore"
uuid = "4f1ea46c-232b-54a6-9b17-cc2d0f3e6598"
version = "0.6.7"
version = "0.6.8"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
17 changes: 12 additions & 5 deletions src/AWSCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,20 @@ Service endpoint URL for `request`.
"""
function service_url(aws, request)
endpoint = get(request, :endpoint, request[:service])
region = "." * aws[:region]
if endpoint == "iam" || (endpoint == "sdb" && region == ".us-east-1") || region=="."
region = aws[:region]
regionless_endpoints = ("iam", "route53")

if endpoint in regionless_endpoints || (endpoint == "sdb" && region == "us-east-1")
region = ""
end
service_host = get(aws,:service_host,"amazonaws.com")
string("https://", endpoint, region, ".", service_host,
request[:resource])

service_host = get(aws, :service_host, "amazonaws.com")

if !isempty(region)
return string("https://", endpoint, ".", region, ".", service_host, request[:resource])
else
return string("https://", endpoint, ".", service_host, request[:resource])
end
end


Expand Down
3 changes: 3 additions & 0 deletions test/aws/ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Resources:
- ssm:GetParameter
Resource:
- !Sub arn:aws:ssm:*:${AWS::AccountId}:parameter/public_ci/AWSCore/ec2_keyfile
- Effect: Allow
Action: route53:GetAccountLimit
Resource: "*"
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
Expand Down
3 changes: 3 additions & 0 deletions test/aws/ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Resources:
Resource:
- !Ref AWSCoreTestJob
- !Ref JobQueue
- Effect: Allow
Action: route53:GetAccountLimit
Resource: "*"

AWSCoreTestJob:
Type: AWS::Batch::JobDefinition
Expand Down
12 changes: 12 additions & 0 deletions test/endpoints.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using AWSCore.Services: route53

@testset "Endpoints" begin
@testset "Route53" begin
try
route53("GET", "/2013-04-01/accountlimit/MAX_HEALTH_CHECKS_BY_OWNER")
@test true
catch
@test false
end
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ aws = aws_config()
include("arn.jl")
include("credentials.jl")
include("exceptions.jl")
include("endpoints.jl")
include("localhost.jl")
include("signaturev4.jl")
include("xml.jl")
Expand Down

2 comments on commit 0da160a

@mattBrzezinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8593

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.8 -m "<description of version>" 0da160afae83101ee58a02e4e7cad68a9ad1631d
git push origin v0.6.8

Please sign in to comment.