Skip to content
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

provider/aws: Retry RunInstance if IAM profile hasn't propagated #2037

Merged
merged 1 commit into from
May 22, 2015

Conversation

catsby
Copy link
Contributor

@catsby catsby commented May 21, 2015

Newly created IAM roles can take a few seconds to propagate.
From Launching an Instance with an IAM Role Using the AWS CLI:

After you create an IAM role, it may take several seconds for the permissions to propagate. If your first attempt to launch an instance with a role fails, wait a few seconds before trying again. For more information, see Troubleshooting Working with Roles in the Using IAM guide.

In testing, this time is typically 5-10 seconds. In this PR, add a simple for loop that tries up to 5 times, sleeping 2 seconds in-between, if and only if we hit an error that matches that kind of failure.

Fixes #1885

@phinze
Copy link
Contributor

phinze commented May 21, 2015

RESILIENCE +5

LGTM! 👍

@JeanMertz
Copy link
Contributor

👍

catsby added a commit that referenced this pull request May 22, 2015
provider/aws: Retry RunInstance if IAM profile hasn't propagated
@catsby catsby merged commit 338bb50 into master May 22, 2015
@catsby catsby deleted the f-aws-iam-instance-bug branch May 22, 2015 11:47
@osterman
Copy link

I think we're seeing a problem related to this. Every now and then we'll get an instance that comes online which has the proper IAM role assigned to it (by name), but it appears to be the ID of the old role. The consequence is that the instance in our case cannot AssumeRole to use AWS APIs. If we taint the aws_instance resource and apply, it usually works, so I don't think it's a misconfiguration on our end.

For the record, we use iam_instance_profile = "${aws_iam_instance_profile.cluster.name}" for each of our hosts, so we're expressing the dependencies to TF.

image

@phinze
Copy link
Contributor

phinze commented Feb 29, 2016

@osterman That's definitely odd! Sounds like it must be upstream misbehavior - the API accepts "name" here so I'm not sure if there's much else we can do on our side? Perhaps something to take up with AWS Support.

If you believe there are steps we should be taking on the Terraform side, feel free to file us a fresh issue!

@ghost
Copy link

ghost commented Apr 27, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provider/aws: iam_instance_profile not yet ready when ec2 instance is launched
4 participants