JuliaCloud / AWS.jl

Julia interface to AWS
MIT License
159 stars 62 forks source link

Cannot successfully get `AWS` config #649

Closed a-cakir closed 1 year ago

a-cakir commented 1 year ago

When running from within a docker image using AWS 1.90, the following leads to time out error

docker run -it julia:1.8.5-buster julia -e 'using Pkg; Pkg.add(PackageSpec(name="AWS", version=v"1.90.0")); using AWS; AWS.global_aws_config()'

HTTP.Request:
HTTP.Messages.Request:
"""
PUT /latest/api/token HTTP/1.1
X-aws-ec2-metadata-token-ttl-seconds: 600
Host: 169.254.169.254
Accept: */*
User-Agent: HTTP.jl/1.8.5
Content-Length: 0
Accept-Encoding: gzip

"""Underlying error:
IOError: read: connection timed out (ETIMEDOUT)
Stacktrace:
omus commented 1 year ago

The error seems to only appear when running this MWE on an EC2 instance

omus commented 1 year ago

We may want to make a follow up issue against HTTP.jl as the connection failure here takes far longer than 1 second to timeout:

julia> e = @time try; HTTP.request("PUT", "http://169.254.169.254/latest/api/token"; connect_timeout=1, retry=false, status_exception=true); catch e; e; end
 11.267654 seconds (206 allocations: 75.328 KiB)
HTTP.Exceptions.RequestError(HTTP.Messages.Request:
"""
PUT /latest/api/token HTTP/1.1
Host: 169.254.169.254
Accept: */*
User-Agent: HTTP.jl/1.8.5
Content-Length: 0
Accept-Encoding: gzip

""", Base.IOError("read: connection timed out (ETIMEDOUT)", -110))

It also appears that this is most of the time spend when getting the credentials:

julia> @time try AWS.global_aws_config(); catch e; e; end
 11.243566 seconds (272 allocations: 82.812 KiB)
Can't find AWS credentials!

I'll make another issue for this.