Skip to content

[Error] Unable to fetch region from EC2 metadata: EC2MetadataRequestError: failed to get EC2 instance identity document #203

Open
@florianakos

Description

@florianakos

Hi

We are running x-ray-daemon @ 3.3.7 (latest at the time) on EC2 instances as part of an ECS task.
Until recently we used to run 3.2.0 but encountered issues when we tried to enforce use of EC2 IMDSv2 via a config setting.
Tried to upgrade to 3.3.7 which I thought would help, but apparently it seems it does not, the daemon fails to start:

2023-08-10T11:42:19Z [Info] Initializing AWS X-Ray daemon 3.3.7
2023-08-10T11:42:23Z [Error] Cannot fetch region variable from config file, environment variables, ecs metadata, or ec2 metadata. Use local-mode to use the local session region.
status code: 401, request id:
caused by: EC2MetadataError: failed to make EC2Metadata request
2023-08-10T11:42:23Z [Error] Unable to fetch region from EC2 metadata: EC2MetadataRequestError: failed to get EC2 instance identity document

After digging in the repository, it seems to me that the issue might be caused by the fact that AWS SDK for GO (v1) does not offer support to seamlessly use IMDSv2:
https://github.com/aws/aws-xray-daemon/blob/56bcdadc0e5808f4428ed6e3e54a88a2ceca2f82/pkg/conn/conn.go#L45C11-L45C11

Based on my research, AWS SDK for GO (v2) should have such support out of the box.
Can you confirm and advise when such support could be expected in x-ray-daemon?
Thanks!

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