-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 Instance profile in path #2729
Comments
@joelthompson Any thoughts here? |
This is because GetCallerIdentity doesn't return the role path (which is very annoying). I think the right way of solving this is the thing we were already discussing offline -- looking up the internal entity ID and then matching against that (as it does get returned by GetCallerIdentity). I've got most of that PR ready, I should have something in the next couple days. |
I think I'm experiencing a similar behavior with ECS. I attach an IAM task role to an ECS task and tried authenticating to vault coming up with a similar error. I tried with both host networking enabled and disabled and got the same message.
|
i'm seeing similar behaviour here when using the ec2 auth type and matching against the bound_iam_role_arn as well. I have a role (and instance profile) which have paths in them. when vault calls GetInstanceProfile, it's ending "path/name" as the query, which throws the below error in the AWS API.
The issue for this seems to be related to the fact that the below like of code, just splits after :instance_profile/ and not necessarily just the last component of the string (i.e. last after /) |
I believe #2802 should fix this. Please comment if not. |
No, #2802 won't fix this. I have a PR about ready (just need to put it through our internal OSS review process) that will fix this. |
@joelthompson Any idea on an ETA for that? Would be good to get it into 0.7.3 if possible. |
This adds a (now-default) option on roles to resolve the bound_iam_principal_arn (when using AWS IAM auth) to AWS's internal unique ID. The primary reason for this is to prevent a particular role or user from being deleted and recreated with the same ARN and thus taking over Vault permissions that were intended to be bound to the previous ARN, which more closely mimics AWS's behavior. By preferentially resolving via the internal unqiue ID rather than the ARN, this also fixes the issue in hashicorp#2729
Similar to hashicorp#2729, the existing implementation for the aws ec2 auth method can't handle an instance profile with a path in the name, when using a bound IAM role. This improves the parsing of the instance profile ARN to eliminate that error.
I think this should be closed now with the 0.7.3 release, it just didn't get auto-closed. @martinssipenko -- can you confirm the newest release works for you? |
Just tested this with vault auth -method=aws header_value=vault.rocks
Error making API request.
URL: PUT https://vault.rocks:8200/v1/auth/aws/login
Code: 400. Errors:
* IAM Principal "arn:aws:sts::123456789012:assumed-role/MyRoleName/i-1234567" does not belong to the role "xxx" Removing the path from ARN, when setting |
Actually, I read the documentation again and it now states that you MUST leave out the path component in So I guess the issue could be closed, but perhaps there is a better way of doing this? Maybe it would be possible to fix this by dropping the path from ARN? @joelthompson @jefferai what do you think? |
@martinssipenko -- are you using the same role you created with 0.7.1 or 0.7.2? If so, update your role to set |
I deleted and created the role, added the |
@joelthompson I'm still hitting this on vault 1.7.1 and can not figure out what i'm doing wrong... I'm trying to go cross-account and have added vault role: From the EC2 I'm always getting: I've followed a few different examples without success. I could move these to |
Hello, @joelthompson. Just like the above commenter I am also still hitting this issue despite changing If it help - I am following the steps outlined here: https://github.com/hashicorp/vault-guides/blob/master/identity/aws-second-sample/AWS-auth-method-testing.md |
One of the less common scenarios - if you've added your iam role to Vault, but then recreated your iam role from AWS side, you'll need delete and re-add it back to Vault. It took me quite sometime to realize it's using RoleID in the authentication. In my case the iam role and Vault are in two different AWS account. Not sure if this also applies if they are in the same account. To see the actual RoleID registered in Vault (bound_iam_principal_id): vault read -namespace= auth/aws/role/<vault_role> |
When using the new IAM auth_type with AWS IAM Instance Profile, which is attached to an IAM role that is in path
/some/
, the ARN of the role isarn:aws:iam::123456789012:role/some/MyRoleName
, but when using this role forbound_iam_principal_arn
argument, error is getting returned. (IAM Principal "arn:aws:sts::123456789012:assumed-role/MyRoleName/i-1234567" does not belong to the role "xxx"
)I did try dropping the path part from ARN and it worked, however, this is not the ARN of the role anymore.
is this a bug or an expected behaviour? If this is expected, I'm happy to send a pull request that would explain this in documentation.
The text was updated successfully, but these errors were encountered: