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

Cannot import a ruleset rule #197

Closed
jhon287 opened this issue Apr 8, 2020 · 7 comments
Closed

Cannot import a ruleset rule #197

jhon287 opened this issue Apr 8, 2020 · 7 comments

Comments

@jhon287
Copy link

jhon287 commented Apr 8, 2020

Hello,

I have an issue when I'm trying to import a ruleset rule:

terraform import pagerduty_ruleset_rule.main <ruleset_rule_id>
pagerduty_ruleset_rule.main: Importing from ID "<ruleset_rule_id>"...
pagerduty_ruleset_rule.main: Import prepared!
  Prepared pagerduty_ruleset_rule for import
pagerduty_ruleset_rule.main: Refreshing state... [id=<ruleset_rule_id>]

Error: GET API call to https://api.pagerduty.com/rulesets//rules/<ruleset_rule_id> failed: 404 Not Found

Terraform Version

Terraform v0.12.21
+ provider.pagerduty v1.6.0

Affected Resource(s)

Please list the resources as a list, for example:

  • pagerduty_ruleset_rule.

Expected Behavior

Rule is imported on Terraform state

Actual Behavior

Rule not found because of wrong API URL.
URL needs to be: https://api.pagerduty.com/rulesets/<ruleset_id>/rules/<ruleset_rule_id>

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform import pagerduty_ruleset_rule.main <ruleset_rule_id>

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@jhon287
Copy link
Author

jhon287 commented Apr 9, 2020

Thanks for fixing the issue...
I've seen that you just merged your PR. I'm waiting the new provider version to be able to import my ruleset rules :)

@stmcallister
Copy link
Contributor

Thanks for pointing this out! Completely slipped my mind to build out the tests for importing, and that lead me to the fact that I didn't fully build out importing. Version 1.6.1 was just released. So, you should now be able to import rulesets and rules.

To import a rule you'll use syntax similar to importing Service Integrations. The ID will be combination of the rulesetID and the rulesetRuleID separated by a .. The command will look like this:

terraform import pagerduty_ruleset_rule.foo  <rulesetID>.<rulesetRuleID>

@jhon287
Copy link
Author

jhon287 commented Apr 9, 2020

It seems working :)
Thank you !

@jhon287 jhon287 closed this as completed Apr 9, 2020
@jhon287
Copy link
Author

jhon287 commented Apr 9, 2020

@stmcallister Sorry for annoying you again, but it seems not working for Catch-All rules...

Error: rpc error: code = Unavailable desc = transport is closing


panic: runtime error: invalid memory address or nil pointer dereference
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x19190b9]
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: 
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: goroutine 86 [running]:
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.flattenConditions(0x0, 0xc0006de840, 0x24, 0xc0006de810)
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4:     /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_ruleset_rule.go:467 +0x29
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: github.com/terraform-providers/terraform-provider-pagerduty/pagerduty.resourcePagerDutyRulesetRuleRead.func1(0xc00077f770)
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4:     /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/pagerduty/resource_pagerduty_ruleset_rule.go:626 +0x217
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: github.com/hashicorp/terraform-plugin-sdk/helper/resource.Retry.func1(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4:     /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/resource/wait.go:22 +0x4e
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState.func1(0xc00050ef60, 0xc0003b0150, 0xc000776900, 0xc0001765a0, 0xc00060fbf8, 0xc00060fbf0)
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4:     /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/resource/state.go:103 +0x29e
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4: created by github.com/hashicorp/terraform-plugin-sdk/helper/resource.(*StateChangeConf).WaitForState
2020-04-09T22:25:39.055+0200 [DEBUG] plugin.terraform-provider-pagerduty_v1.6.1_x4:     /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-pagerduty/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/resource/state.go:80 +0x1b9
2020/04/09 22:25:39 [ERROR] <root>: eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2020/04/09 22:25:39 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/04/09 22:25:39 [TRACE] [walkImport] Exiting eval tree: import pagerduty_ruleset_rule.tunz_monizze_catchall result
2020/04/09 22:25:39 [TRACE] vertex "import pagerduty_ruleset_rule.tunz_monizze_catchall result": visit complete
2020/04/09 22:25:39 [TRACE] vertex "pagerduty_ruleset_rule.tunz_monizze_catchall (import id \"561c5aae-e2e5-4708-baa7-48c7251573fb.61f0f3de-eb7c-426a-b8dc-0ab11ea6b80f\")": dynamic subgraph encountered errors
2020/04/09 22:25:39 [TRACE] vertex "pagerduty_ruleset_rule.tunz_monizze_catchall (import id \"561c5aae-e2e5-4708-baa7-48c7251573fb.61f0f3de-eb7c-426a-b8dc-0ab11ea6b80f\")": visit complete
2020/04/09 22:25:39 [TRACE] dag/walk: upstream of "provider.pagerduty (close)" errored, so skipping
2020/04/09 22:25:39 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020-04-09T22:25:39.057+0200 [DEBUG] plugin: plugin process exited: path=/Users/jsabbe/Bitbucket/terraform-pagerduty/.terraform/plugins/darwin_amd64/terraform-provider-pagerduty_v1.6.1_x4 pid=49271 error="exit status 2"
2020/04/09 22:25:39 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-04-09T22:25:39.057+0200 [DEBUG] plugin: plugin exited

@stmcallister
Copy link
Contributor

doh! Okay. Sorry about that. I should be able to push out a fix early next week.

@swhyte-taos
Copy link

Not sure if this is exactly what @jhon287 was referring to; but there's no documented way to create a catch_all rule with the provider.

The upstream API appears to support it, but catch_all is not a valid variable:

Error: Unsupported argument

  on main.tf line 424, in resource "pagerduty_ruleset_rule" "catchall":
 424:   catch_all = true

An argument named "catch_all" is not expected here.

make: *** [plan] Error 1

@stmcallister
Copy link
Contributor

When you create a ruleset it automatically creates a catch_all rule for you. But, you're right. You should be able to import that so you can manage it. I'll get on that in the next day or so.

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