In my case problem was on AWS config side Metadata server wasn't accessible from container
This ticket helps me Using IMDS (v2) with token inside docker on EC2 or ECS