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

Error on EC2 instance role change #8262

Closed
limitusus opened this issue Apr 10, 2019 · 1 comment · Fixed by #11104
Closed

Error on EC2 instance role change #8262

limitusus opened this issue Apr 10, 2019 · 1 comment · Fixed by #11104
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@limitusus
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.13
+ provider.aws v2.5.0

Affected Resource(s)

  • aws_instance

Terraform Configuration Files

resource "aws_instance" "host0001" {
  ami           = "ami-086063d8c95bfa211"
  instance_type = "t3.medium"
  ebs_optimized = "true"
  subnet_id     = "sg-12345678"

  vpc_security_group_ids = [
    "sg-xxxxxxxx",
  ]

  iam_instance_profile = "my-profile"

  tags {
    Name = "host0001"
  }
}

Debug Output

https://gist.github.com/limitusus/429bef80ba7ffc7af90083c886e048f6

Panic Output

No Panic

Expected Behavior

IAM profile change is only supported for "running" instances, so for "stopped" instances, remove the attached profile and then attach a new profile.

Actual Behavior

terraform tries to switch profile directly regardless of the instance's state and causes error.

Steps to Reproduce

  1. Prepare .tf file for an EC2 instance with profile A
  2. terraform apply and the instance is created
  3. stops the instance
  4. Edit .tf file for the EC2 instance with different profile B
  5. terraform apply again and error reproduces

Important Factoids

References

AWS document says

To replace the IAM role on an instance that already has an attached IAM role, the instance must be in the running state.

@nywilken nywilken added the service/ec2 Issues and PRs that pertain to the ec2 service. label Apr 26, 2019
@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 24, 2019
@ryndaniels ryndaniels added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 21, 2019
@ryndaniels ryndaniels self-assigned this Nov 21, 2019
@ghost
Copy link

ghost commented Mar 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost unassigned ryndaniels Mar 27, 2020
@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants