-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Bad error message if instance profile assume role policy is wrong #2060
Comments
I can confirm this. Here is my debug logs:
Looks like we should check if there is an error message if the access or secret access keys are missing. |
Based on the above I would suggest this bug should be raised against botocore rather than this repo, since that's the component which cycles through various AWS auth methods trying and then ultimately failing to get access. awscli is just relaying the exception. |
For the next guy coming here with the same error and no clue what's happening: |
thanks @jobwat - that saved my butt today!!! |
Since this is such a poor error, here's how to get the underlying error - use your IAM role name in the |
I was just getting a non-descript hex string back After adding --debug, found
|
It looks like this is the current error message you would see:
@rvandegrift do you think that message is sufficient or did you have any other feedback? |
@tim-finnigan No - it might be better than before, but it's not correct. That message would lead me to look at the IAM policies assigned to the instance profile role instead of the role's assume role policy. @rsalmond's point in #2060 (comment) seems right. botocore should detect that the instance profile failed due to this misconfiguration, and raise a more useful exception. Then, awscli can handle that exception however it does to provide the feedback to the user. |
Hi @rvandegrift, thanks for your feedback. I created an instance profile and received the following error when testing this:
Does that error message provide the clarity you were looking for? Please let me know if I misunderstood your workflow in this example. |
@tim-finnigan that's not quite the right scenario. You have a correctly configured IAM profile, but the attached policies don't permit the instance to call I just reproduced this. The current behavior is better - it doesn't crash. But it's just reported as a generic failure to load credentials:
Ideally, the error from the metadata service could be passed to the user, since it pinpoints the problem exactly:
Here's a full walk-through to reproduce this. You'll need to substitute appropriate values for your subnet, security groups, and key name when creating the instance. NB: the EC2 console won't let you launch an instance with this IAM role, you need to use the cli. First, create the IAM role and instance profile:
Note that the assume role policy does not permit Second, launch an instance using this profile:
Wait a bit for a public IP to be assigned... then login, and:
|
@rvandegrift thanks for providing that walk-through, I was able to reproduce the behavior you’re seeing. But I don’t think this has to do with the role:
In this premium support article on troubleshooting CLI issues with EC2 it says to “Verify that the AWS CLI is installed and configured correctly.” If you configure your CLI do you still get an error when running |
@tim-finnigan If there's no config, In the misconfiguration that this issue is about, EC2 is unable to call STS because the assume role policy does not permit it. The metadata service's error (now [2], but my first post has an older link that's also helpful) explains how to fix the issue - but To verify all of this, follow the above but change the assume role policy on the IAM role to permit
[1] - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html |
Thanks @rvandegrift for the explanation and sorry for the confusion on my end! I understand what you’re saying now and could reproduce that. I can see the need for a clearer error message in this scenario. |
…s#2060) Co-authored-by: Tarun <c2tarun@users.noreply.github.com>
Getting security credentials from Instance Metadata Service fails when an EC2 instance does not have permissions to assume a role. When that happens, we get a very unhelpful error message "Value cannot be null. (Parameter 'awsAccessKeyId')" Do response validation so that we get better exception message. See also aws/aws-cli#2060
We had an instance profile with a misconfigured role - the assume role policy didn't permit ec2.amazonaws.com. awscli gets very confusing:
It'd be nice if awscli could return the helpful error message from the meta-data API:
Thanks,
Ross
The text was updated successfully, but these errors were encountered: