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

'terraform apply' with deleted coupon in state gives error code 'resource_missing' #46

Open
jlucktay opened this issue Apr 23, 2021 · 2 comments

Comments

@jlucktay
Copy link

Hi there, and thank you for this provider! Looking forward to making use of it.
I was fiddling with some of the basic usage stuff outlined in the README and ran into a snag.

  1. Created the example MLK coupon with code = "MLK_DAY"
  2. Changed the code value in my .tf file
  3. Ran terraform apply --auto-approve
  4. Noted in the Stripe Dashboard UI that the coupon code did not change, and remained as MLK_DAY
  5. Ran terraform apply --auto-approve again
  6. Coupon code still stubbornly staying on MLK_DAY
  7. Deleted coupon manually in Stripe Dashboard UI
  8. Ran terraform apply --auto-approve again and got the following:
Error: {
  "code": "resource_missing",
  "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
  "status": 404,
  "message": "No such coupon: 'MLK_DAY'",
  "param": "coupon",
  "request_id": "req_bCoPRMtuRHTxLW",
  "type": "invalid_request_error"
}

Will take a quick look and see if I can put a PR together to straighten things out.

The 2 issues as I see them:

  • can't update coupon code, even if it requires deletion and (re)creation of said coupon
  • if coupon was previously created by Terraform but then deleted outside of a Terraform operation, Terraform should handle it a little more gracefully, and probably attempt to recreate as it sees fit
@mpereira
Copy link

For other folks landing on this issue with the same problem: a workaround is to manually remove all resources that this TF provider reports as missing and then re-running TF plan/apply.

For example, for an output like this:

$ terraform apply
Acquiring state lock. This may take a few moments...
stripe_plan.tier_0_monthly_subscription: Refreshing state... [id=plan_JMq4PtQeTJIdrZ]

Error: {"code":"resource_missing","doc_url":"https://stripe.com/docs/error-codes/resource-missing","status":404,"message":"No such plan: 'plan_JMq4PtQeTJIdrZ'","param":"plan","request_id":"req_hdinACXCrr1Mw0","type":"invalid_request_error"}

Running

terraform state rm 'stripe_plan.tier_0_monthly_subscription'

and then re-running terraform apply would likely fix the problem. It's possible that the TF provider will complain of other missing resources, so just keep terraform state rming them until it doesn't complain.

@qck4fun
Copy link

qck4fun commented Mar 9, 2023

Is removing resources manually considered as final resolution? It is quite unfortunate to solve it this way I think.

@franckverrot do you plan to address this? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants