-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAM Policy attached to EC2 not working when ran from inside Docker container #540
Comments
It looks like you are running into a timeout |
Hello! We had the exact same problem and we managed to find a workaround (increasing the timeout as suggested above didn't work): How we figured out what was the problem: There was this similar problem with aws go sdk in the past: In a container environment, if the hop limit is 1, the IMDSv2 response does not return because going to the container is considered an additional network hop. So it means that, running the rust code into docker, instead of We added 2 new extra docker machine settings and works fine now:
|
Thanks cataliw for that workaround. Does this work for you user9747? |
FYI I have reproduced the issue and fixed by those 2 new extra docker machine settings:
Is it worth adding somewhere to docs? |
closing since this isn't a bug—a doc PR is open |
|
hi catalinw, i referred to AWS doc and found no such aws ec2 modify-instance-metadata-options \
--instance-id {inst_id} \
--http-tokens required \
--http-endpoint enabled \
--http-put-response-hop-limit 2 Will it work the same way or could you provide an example to show how and where to configure such parameters ? |
For anyone else that stumbles upon this:
Therefore the increase in hop limit is not really a workaround, it is the solution. I thought I'd just make the situation clear in case someone else wastes a bunch of time trying to figure out why their existing code works but it stops working when aws-sdk-rust is used instead. |
Describe the bug
The EC2 instance i use has a IAM Role attached to it which allows GetObject from s3 bucket.
The above code work if run it on the host EC2, but doesn't work if run it in a docker. Also i found that it works if set the docker to run with network as host.
Expected Behavior
Attached iam role not picked up by AWS sdk inside docker
Current Behavior
For some reason imds is not working from inside docker.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
Version
aws-config = "0.12.0" aws-sdk-s3 = "0.12.0"
Environment details (OS name and version, etc.)
ubuntu
Logs
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation;
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; operation="GetObject"
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; service="s3"
[2022-05-22T19:44:03Z INFO aws_config::default_provider::credentials] provide_credentials; provider=default_chain
[2022-05-22T19:44:03Z INFO aws_config::meta::credentials::chain] provider in chain did not provide credentials provider=Environment context=environment variable not set
[2022-05-22T19:44:03Z INFO aws_config::meta::credentials::chain] provider in chain did not provide credentials provider=Profile context=No profiles were defined
[2022-05-22T19:44:03Z INFO aws_config::meta::credentials::chain] provider in chain did not provide credentials provider=WebIdentityToken context=$AWS_WEB_IDENTITY_TOKEN_FILE was not set
[2022-05-22T19:44:03Z INFO aws_config::meta::credentials::chain] provider in chain did not provide credentials provider=EcsContainer context=ECS provider not configured
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation;
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; operation="get"
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; service="imds"
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation;
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; operation="get-token"
[2022-05-22T19:44:03Z INFO aws_smithy_http_tower::parse_response] send_operation; service="imds"
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; status="dispatch_failure"
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; message=timeout: HTTP read timeout occurred after 1s
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; status="construction_failure"
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; message=Failed to load session token: timeout: HTTP read timeout occurred after 1s
[2022-05-22T19:44:04Z INFO aws_config::meta::credentials::chain] provider in chain did not provide credentials provider=Ec2InstanceMetadata context=could not communicate with imds: timeout: HTTP read timeout occurred after 1s
[2022-05-22T19:44:04Z INFO aws_http::auth] provider returned CredentialsNotLoaded, ignoring
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; status="construction_failure"
[2022-05-22T19:44:04Z INFO aws_smithy_http_tower::parse_response] send_operation; message=No credentials in the property bag
The text was updated successfully, but these errors were encountered: