Describe the feature
When the ECS task metadata credentials endpoint returns HTTP 429 (rate limited), the Ruby SDK raises Aws::Errors::MissingCredentialsError. in my case the complete error was:
Error Class: Aws::Errors::MissingCredentialsError
Message: unable to sign request without credentials set
FULL STACK TRACE:
0: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/sign.rb:145:in `rescue in sign'
1: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/sign.rb:136:in `sign'
2: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/sign.rb:48:in `call'
3: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/transfer_encoding.rb:27:in `call'
4: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/helpful_socket_errors.rb:12:in `call'
5: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/retry_errors.rb:365:in `block in call'
6: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/user_agent.rb:92:in `metric'
7: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/retry_errors.rb:385:in `with_metric'
8: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/retry_errors.rb:365:in `call'
9: /usr/local/bundle/gems/aws-sdk-core-3.241.4/lib/aws-sdk-core/plugins/http_checksum.rb:20:in `call'
This is misleading because credentials are not missing—they are being rate-limited by the ECS agent. misleading my troubleshooting efforts
The Python SDK (boto3/botocore) provides a much clearer error message that includes the HTTP status code and the actual response from the endpoint.
Python SDK (for comparison):
botocore.exceptions.CredentialRetrievalError: Error when retrieving credentials from container-role: Error retrieving metadata: Received non 200 response 429 from container metadata: You have reached maximum request limit.
The ECS agent logs do not help either as there were no rate limiting errors in the agent logs. I had to run a tcp dump command below to troubleshoot the issue:
sudo tcpdump -i any -A port 80 and host 169.254.170.2 2>/dev/null | grep -E "HTTP/1\.[01] (200|429|503)"
Use Case
When running applications on Amazon ECS with IAM task roles, the ECS agent enforces rate limiting on the credentials endpoint (http://169.254.170.2/v2/credentials/) via the ECS_TASK_METADATA_RPS_LIMIT configuration (default: 40 steady, 60 burst requests per second).
When this rate limit is exceeded, the ECS agent returns HTTP 429 with the body: You have reached maximum request limit.
The current Ruby SDK error message leads developers to debug credential provider chain configuration burning hours investigating the wrong problem When the actual issue is simply rate limiting, which can be resolved by Caching/reusing SDK clients instead of creating new ones per request or adjusting ECS_TASK_METADATA_RPS_LIMIT on the ECS agent.
References
[1] https://github.com/aws/amazon-ecs-agent/blob/master/README.md#:~:text=ECS_TASK_METADATA_RPS_LIMIT
Proposed Solution
Include HTTP status code and response body in the error message
Other Information
No response
Acknowledgements
SDK version used
3.241.4
Environment details (OS name and version, etc.)
amazonlinux 2023
Describe the feature
When the ECS task metadata credentials endpoint returns HTTP 429 (rate limited), the Ruby SDK raises Aws::Errors::MissingCredentialsError. in my case the complete error was:
This is misleading because credentials are not missing—they are being rate-limited by the ECS agent. misleading my troubleshooting efforts
The Python SDK (boto3/botocore) provides a much clearer error message that includes the HTTP status code and the actual response from the endpoint.
Python SDK (for comparison):
The ECS agent logs do not help either as there were no rate limiting errors in the agent logs. I had to run a tcp dump command below to troubleshoot the issue:
Use Case
When running applications on Amazon ECS with IAM task roles, the ECS agent enforces rate limiting on the credentials endpoint (http://169.254.170.2/v2/credentials/) via the ECS_TASK_METADATA_RPS_LIMIT configuration (default: 40 steady, 60 burst requests per second).
When this rate limit is exceeded, the ECS agent returns HTTP 429 with the body: You have reached maximum request limit.
The current Ruby SDK error message leads developers to debug credential provider chain configuration burning hours investigating the wrong problem When the actual issue is simply rate limiting, which can be resolved by Caching/reusing SDK clients instead of creating new ones per request or adjusting ECS_TASK_METADATA_RPS_LIMIT on the ECS agent.
References
[1] https://github.com/aws/amazon-ecs-agent/blob/master/README.md#:~:text=ECS_TASK_METADATA_RPS_LIMIT
Proposed Solution
Include HTTP status code and response body in the error message
Other Information
No response
Acknowledgements
SDK version used
3.241.4
Environment details (OS name and version, etc.)
amazonlinux 2023