Skip to content

IMDS fails on GitHub Actions runner #721

@omus

Description

@omus

I noticed this when adding some doctests. We may need to do some improved detection to determine if the webserver is the IMDS server.

Issue encountered:

Error: doctest failure in ~/work/AWS.jl/AWS.jl/src/AWS.jl:148-158

```jldoctest service
julia> using AWS: @service

julia> @service STS
STS

julia> STS.get_caller_identity()
OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}}, Vector{Any}} with 2 entries:
  "GetCallerIdentityResult" => LittleDict{Union{String, Symbol}, Any, Vector{Un…
  "ResponseMetadata"        => LittleDict{Union{String, Symbol}, Any, Vector{Un…
```

Subexpression:

STS.get_caller_identity()

Evaluated output:

ERROR: HTTP.Exceptions.StatusError(400, "PUT", "/latest/api/token", HTTP.Messages.Response:
"""
HTTP/1.1 400 Bad Request
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/10.0
Date: Thu, 12 Jun 2025 16:13:12 GMT
Content-Length: 322

<?xml version="1.0" encoding="utf-8"?>
<Error xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Code>InvalidHttpVerb</Code>
    <Message>The HTTP verb specified was not recognized by the server.</Message>
    <Details>'PUT' is not a supported verb.</Details>
</Error>""")
Stacktrace:
  [1] refresh_token!(session::AWS.IMDS.Session, duration::Int16)
    @ AWS.IMDS ~/work/AWS.jl/AWS.jl/src/IMDS.jl:94
  [2] refresh_token!
    @ ~/work/AWS.jl/AWS.jl/src/IMDS.jl:53 [inlined]
  [3] request(session::AWS.IMDS.Session, method::String, path::String; kwargs::@Kwargs{})
    @ AWS.IMDS ~/work/AWS.jl/AWS.jl/src/IMDS.jl:104
  [4] request
    @ ~/work/AWS.jl/AWS.jl/src/IMDS.jl:100 [inlined]
  [5] get(session::AWS.IMDS.Session, path::String)
    @ AWS.IMDS ~/work/AWS.jl/AWS.jl/src/IMDS.jl:168
  [6] get
    @ ~/work/AWS.jl/AWS.jl/src/IMDS.jl:180 [inlined]
  [7] ec2_instance_credentials(profile::String)
    @ AWS ~/work/AWS.jl/AWS.jl/src/AWSCredentials.jl:233
  [8] (::AWS.var"#12#18"{String})()
    @ AWS ~/work/AWS.jl/AWS.jl/src/AWSCredentials.jl:132
  [9] AWS.AWSCredentials(; profile::Nothing, throw_cred_error::Bool)
    @ AWS ~/work/AWS.jl/AWS.jl/src/AWSCredentials.jl:138
 [10] AWSCredentials
    @ ~/work/AWS.jl/AWS.jl/src/AWSCredentials.jl:113 [inlined]
 [11] AWS.AWSConfig()
    @ AWS ~/work/AWS.jl/AWS.jl/src/AWSConfig.jl:32
 [12] #global_aws_config#89
    @ ~/work/AWS.jl/AWS.jl/src/AWS.jl:82 [inlined]
 [13] global_aws_config
    @ ~/work/AWS.jl/AWS.jl/src/AWS.jl:80 [inlined]
 [14] get_caller_identity()
    @ STS ~/work/AWS.jl/AWS.jl/src/services/sts.jl:722
 [15] top-level scope
    @ none:1

Expected output:

OrderedCollections.LittleDict{Union{String, Symbol}, Any, Vector{Union{String, Symbol}}, Vector{Any}} with 2 entries:
  "GetCallerIdentityResult" => LittleDict{Union{String, Symbol}, Any, Vector{Un…
  "ResponseMetadata"        => LittleDict{Union{String, Symbol}, Any, Vector{Un…

Originally posted by @omus in #720 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions