-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
aws provider allowed_account_ids does not work with iam instance profile #3431
Comments
Terraform version: 0.6.3 |
@mnylen are you providing IAM keys as well? or just the region and allowed_account_ids? |
@stack72 I don't think he is.
which means that credentials are coming from the internal metadata service. |
This is handled in It looks like the implementation is to call iam:GetUser with no The particular error you are getting seems to have been fixed in b95e7a9, where it became silently ignored. However, I think a bug may still remain here: if the So all of this is to say: as currently implemented it doesn't look like |
@radeksimko d'oh! Missed that :( |
It looks like in the case where we're running with instance credentials we can get an instance profile ARN from the metadata endpoint Perhaps it would be sensible to detect whether we got the credentials from the environment or from the instance metadata, and do the account checks differently in the latter case so we'll get the right result from the metadata API. |
That looks like a good plan. 👍 |
There doesn't appear to be a great solution for identifying the current account (they're all hacks) when dealing with IAM/STS assume-role generated credentials. Since an account always has security groups - you could pull the
|
I'm afraid this isn't true. It is possible to remove the default ones in the default VPC and I wouldn't rely on any security groups outside of default VPC either. You don't really need any SGs in cases where you're running background jobs for example. I think that gracefully falling back to the metadata endpoint if IAM call fails is ok. {
"Code" : "Success",
"LastUpdated" : "2015-10-28T16:49:39Z",
"InstanceProfileArn" : "arn:aws:iam::101636750127:instance-profile/aws-elasticbeanstalk-ec2-role",
"InstanceProfileId" : "AIPAREU6ES7PV7RYRYPIC"
} |
Right... I think it doesn't even need to be implemented as a fallback, because Terraform "knows" whether it got the credentials from the instance metadata, and so it knows it's using an instance profile without needing to try the initial |
Hey all – doing a review of old issues , is this still relevant? |
This is still relevant. Essentially #3313 caused that |
As a fallback when a user name is not provided (i.e. STS roles/credentials) why not attempt to grab the first IAM user's ARN within the account and parse out that user's account ID. It would require the It's certainly a hack but it'll work since all users within an account will have the same ID and terraform requires at least one user to exist. |
I hit this problem while using terraform and STS outside of an instance (i.e. where instance metadata is not available) |
d'oh looks like #4290 may solve the problem |
See #5030 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
With this provider config, terraform apply fails when running on EC2 instance with IAM instance profile. The error message I'm getting this:
If I remove the allowed_account_ids attribute, it starts to work.
The text was updated successfully, but these errors were encountered: