hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.28k stars 1.72k forks source link

Docs for google_monitoring_alert_policy have incorrect import instructions #18463

Open red8888 opened 2 months ago

red8888 commented 2 months ago

Community Note

Terraform Version & Provider Version(s)

Any

Affected Resource(s)

Docs: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy#import

Terraform Configuration

NA

Debug Output

No response

Expected Behavior

No response

Actual Behavior

No response

Steps to reproduce

No response

Important Factoids

No response

References

See previously closed issue: https://github.com/hashicorp/terraform-provider-google/issues/7693

Still a problem I just got bit by this. That issue has a PR with the doc update ^ can someone merge that?

Also, even more annoying, I can't figure out how to get the ID of a policy, how the heck do you get this info? I had to terraform a policy just so I could look at the state output and see the number.

b/348474289

ggtisc commented 2 months ago

Confirmed issue!

It is possible to import other resources, but not a google_monitoring_alert_policy with next steps:

  1. Have created a google_monitoring_alert_policy (can use this example)
  2. Have the basic code in terraform code for the imported resource:

resource "google_monitoring_alert_policy" "alert_policy" { display_name = "alert-policy-18463" combiner = "OR" conditions { display_name = "test condition" } }

  1. Execute the command terraform import google_monitoring_alert_policy.alert_policy {{alert-policy-18463}}

Output: Error creating AlertPolicy: googleapi: Error 400: Field alert_policy.conditions[0].condition_case had an invalid value of "0": Condition subtype (e.g. "condition_absent","condition_threshold", etc.) is absent or unknown.