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

emr: terraform state containing very old terminated cluster causes plan to fail #7783

Closed
ghost opened this issue Mar 1, 2019 · 7 comments · Fixed by #16924
Closed

emr: terraform state containing very old terminated cluster causes plan to fail #7783

ghost opened this issue Mar 1, 2019 · 7 comments · Fixed by #16924
Assignees
Labels
bug Addresses a defect in current functionality. service/emr Issues and PRs that pertain to the emr service.
Milestone

Comments

@ghost
Copy link

ghost commented Mar 1, 2019

This issue was originally opened by @steliospaps as hashicorp/terraform#20531. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform v0.11.7

  • Downloading plugin for provider "aws" (2.0.0)

I cannot easily test with 0.11.11 because I do not own the build server where this runs.

EMR cluster was manually terminated in dec 10th 2018. When I run terraform plan in feb 28th 2019 to create it, it failed.

I believe it failed because the EMR cluster history in aws goes back only two months, so the lookup for the cluster fails.

Workaround: I had no other resources in that terraform config, so I deleted the statefile. If I had other resources I would not be able to do that.

output (anonymised):

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

....

Error: Error refreshing state: 1 error(s) occurred:

  • aws_emr_cluster.XXXXXXXXX: 1 error(s) occurred:

  • aws_emr_cluster.XXXXXXXX: aws_emr_cluster.XXXXXXXX: Error reading EMR cluster: InvalidRequestException: Cluster id 'j-XXXXXXXXXX' is not valid.
    status code: 400, request id: XXXXXXX-XXXXXX-XXXX-XXXX-XXXXXXXXX

@bflad bflad added bug Addresses a defect in current functionality. service/emr Issues and PRs that pertain to the emr service. labels Mar 1, 2019
@bflad
Copy link
Contributor

bflad commented Mar 1, 2019

Hi @steliospaps 👋 Thanks for reporting this and sorry for the trouble. This is certainly something that can be addressed by removing the resource during refresh, e.g.

if isAWSErr(err, emr.ErrCodeInvalidRequestException, "is not valid") {
  log.Printf("[DEBUG] EMR Cluster (%s) not found, removing from state", d.Id())
  d.SetId("")
  return nil
}

We have some currently in-flight bugfix work occurring right now with that resource (#7405) so it may get included with that or can be fixed right afterwards.

@ImDevinC
Copy link

ImDevinC commented Jun 4, 2019

Was a solution for this ever implemented? You can fix this without fully destroying the state by using terraform state rm aws_emr_cluster.XXXXXX, but not having to do that would be great

@klsnreddy
Copy link

Is there a fix for this, apart from removing that resource from state file, I am getting this exception while I am trying to destroy terrafrom resource also, my cluster is Active and I need to terminate the cluster, when I say 'terraform destroy', I am getting this same exception.

@chernetsov
Copy link

Bumping this. We've stumbled into this too. Doing terraform state rm aws_emr_cluster ... for now.

@bflad bflad self-assigned this Jan 4, 2021
@bflad bflad added this to the v3.23.0 milestone Jan 4, 2021
@bflad
Copy link
Contributor

bflad commented Jan 6, 2021

A best effort fix for this has been merged and will release with version 3.23.0 of the Terraform AWS Provider, likely tomorrow. Thanks to @apetresc for the implementation and testing. 👍

@ghost
Copy link
Author

ghost commented Jan 8, 2021

This has been released in version 3.23.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link
Author

ghost commented Feb 5, 2021

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 locked as resolved and limited conversation to collaborators Feb 5, 2021
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/emr Issues and PRs that pertain to the emr service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants