The access key id and the secret access key when within ECS must be fetched from the endpoint http://169.254.170.2/v2/credentials/UUID, which can be more commonly accessed with the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable this way: http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.
Using IMDS' endpoint 169.254.169.254/latest/api/token is problematic as it will try to use the instance role rather than the container role if it works at all.
The access key id and the secret access key when within ECS must be fetched from the endpoint
http://169.254.170.2/v2/credentials/UUID, which can be more commonly accessed with theAWS_CONTAINER_CREDENTIALS_RELATIVE_URIenvironment variable this way:http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.Using IMDS' endpoint 169.254.169.254/latest/api/token is problematic as it will try to use the instance role rather than the container role if it works at all.