aws / aws-xray-daemon

The AWS X-Ray daemon listens for traffic on UDP port 2000, gathers raw segment data, and relays it to the AWS X-Ray API.
Apache License 2.0
190 stars 69 forks source link

[Error] Cannot fetch region variable from config file, environment variables, ecs metadata, or ec2 metadata. #191

Open jcquiles opened 1 year ago

jcquiles commented 1 year ago

Hello I cant seem to figure out exactly what is being asked here. I am just trying to run a test locally to get a clear idea of how to get a django application configured with xray before even applying it to an ecs fargate cluster, which is the primary goal.

I tried setting credentials and region as environment variables locally and inside .aws/credentialsbut am still getting the same result. The container exits as soon as docker-compose file is ran.

Here is the full error.

➜  mysite git:(main) ✗ docker logs -f e8e58775c8ff
2023-02-20T23:50:51Z [Info] Initializing AWS X-Ray daemon 3.3.6
2023-02-20T23:50:51Z [Info] Using buffer memory limit of 78 MB
2023-02-20T23:50:51Z [Info] 1248 segment buffers allocated
2023-02-20T23:50:51Z [Error] Cannot fetch region variable from config file, environment variables, ecs metadata, or ec2 metadata. Use local-mode to use the local session region

Here is the docker-compose file.

`version: '3'

services:
    web:
        build: .
        command: python manage.py runserver 0.0.0.0:8000
        ports:
            - 8000:8000
        links:
            - xray
        environment:
            XRAY_DAEMON_ADDRESS: xray:2000
            AWS_REGION: us-east-2

    xray:
        image: amazon/aws-xray-daemon
        entrypoint: /usr/bin/xray --local-mode -o`

Is there another solution here if the problem is not the credentials? Thank you!

jj22ee commented 1 year ago

Hi, I have 2 different suggestions 1) The environment variables may be isolated between the 2 containers. You have to define the env variable AWS_REGION for the xray container as well. 2) If first option doesn't work, try changing /usr/bin/xray --local-mode -o to /usr/bin/xray --local-mode -o -n us-east-2

Also, you do not need both --local-mode and -o, as they are both the same command line option