-
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
Invalid IAM Instance Profile name #15341
Comments
By the way, I am able to successfully change an existing EC2 instance's IAM Role to search-api-instance-profile manually via AWS console (as in https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/), so it's a valid instance profile. Must be a bug in terraform |
It started working, I must have missed smth originally. Closing as not an issue |
This happened to me as well. There seems to be some race condition for newly created profiles. When I wait a short period and rerun the terraform it succeeds. |
@aleybovich I think you should reopen this. |
seeing same issue, @jsravn thanks for work-around |
@aleybovich - I'm facing the same issue. You have to reopen the case as suggested by @jsravn |
@aleybovich +1 to reopen as I just hit this as well. |
I'm no longer able to reproduce after I took down my whole envo and rebuilt. You guys need to reopen with your steps to reproduce |
This is an intermittent error, where something that relies on IAM later in the cycle (usually immediately) cannot find the IAM resource. This is probably Amazon internal delay in actually making the resource available everywhere although the resource has been successfully created to Terraform. In my case, a simple re-run of Terraform got me past this. I hit it every now and then and now recognize it so I know what to do. Suggested remedies: resources that require IAM resources specifically check that they are available before creation? Terraform will have marked them as created, but they may not be ready yet, so maybe a double-check is in order? This only seems to happen with Instance Profiles. |
I get the same behavior - rerun terra and it goes away. |
I think this is probably hashicorp/terraform-provider-aws#838 |
Just seen this as well. |
I get the same behavior, but with Ansible... so I waited for a couple minutes.. run again... and OK! No more issues!... as @spanktar said... I think that is an AWS internal delay! |
Seeing this too. |
Also ran into this. |
seeing this as well..This also seems to happen apparently on change, not just on create!
Second run all ok! |
Seeing this as well. Looks like a race. |
@apparentlymart Petition to re-open? |
Seeing this again with
|
@six0h Are you getting the same error with ansible ? (InvalidParameterValue) Quick google found this thread at AWS. According to AWS there is a hardcoded 2min delay for creating instance profiles, yet if you look at my example Terraform is reporting
|
Also encountering this bug. |
Me also. |
Me also |
I've been facing it about two hours and it still does not work... |
Here's a horrifying hack I used somewhere else to deal with bad timing issues. Maybe this would help in this scenario as well, adjust resource types to suit your needs: resource "aws_appautoscaling_policy" "ecs_asp_up_eap" {
name = "tweedle"
resource_id = "service/beetle"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_lower_bound = 0
scaling_adjustment = 3
}
}
depends_on = ["null_resource.timer"]
}
resource "null_resource" "timer" {
provisioner "local-exec" {
command = "sleep 9"
}
triggers {
trigger = "${aws_appautoscaling_target.ecs_asp_target_eap.resource_id}"
}
} |
I have the same issue. |
Just to confirm the suspicion, I am not using terraform but am instead using javascript sdk in nodejs to first create the Instance Profile and then to associate it with the instance, and I get the same problem -> if I try to do association with instance immediately after, it will say Instance Profile does not yet exist. However, if I do it somewhat later, it will work. |
Hi folks, as suggested above and noted in the AWS IAM documentation, you are running against the eventual consistency nature of the IAM service. In v1.7.1 of the AWS provider (specifically PR hashicorp/terraform-provider-aws#3055), we now appropriately retry for up to a minute on this particular condition of associating or re-associating IAM instance profiles with EC2 instances, which should cover the most common scenarios. We will adjust that retry period if necessary based on feedback. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading your AWS provider. PS: If something is still wrong after that upgrade, I would highly suggest opening a new issue in the provider repository: https://github.com/terraform-providers/terraform-provider-aws |
I am facing this issue even in the latest terraform Docker Image, when trying to create instance by attaching it to existing IAM Instance Profile. Even tried hitting thrice, got the same error.
When I try listing the IAM role via AWS CLI, it lists it and also visible via console. |
Hi all, New issues with the terraform aws provider should be opened in the aws provider repository. Because this closed issue is generating notifications for subscribers, I am going to lock it and encourage anyone experiencing issues with the aws provider to open tickets there. Please continue to open issues here for any other terraform issues you encounter, and thanks! |
I have created an instance role and profile as following:
Now, I add an EC2 instance:
And I get the floowing error:
Now, if I go check the role
code-deploy-ec2-instance-profile
in teh console, I see that it's Instrance Profile ARN is empty (but if i create an EC2 role via the AWS console it shows a valid ARN).Any ideas if it's a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered: