You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
If an issue is assigned to a user, that user is claiming responsibility for the issue.
Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.
Create a resource successfully when run terraform apply.
Actual Behavior
terraform apply fails because API returns status code 400 as follows:
$ terraform apply
<snip>
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:+ create
Terraform will perform the following actions:# google_monitoring_alert_policy.alert_policy will be created+resource"google_monitoring_alert_policy""alert_policy" {
+combiner="OR"+creation_record=(known after apply)
+display_name="My Alert Policy"+enabled=true+id=(known after apply)
+name=(known after apply)
+project="<masked>"+conditions {
+display_name="test condition"+name=(known after apply)
+condition_threshold {
+comparison="COMPARISON_GT"+duration="60s"+filter="metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""+aggregations {
+alignment_period="60s"+per_series_aligner="ALIGN_RATE"
}
}
}
+documentation {
+mime_type="text/markdown"+subject="baz"
}
}
Plan:1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
google_monitoring_alert_policy.alert_policy: Creating...
╷
│ Error: Error creating AlertPolicy: googleapi: Error 400: Request was missing field alert_policy.documentation.mime_type: non-empty content requires non-empty MIME type and vice versa.
│
│ with google_monitoring_alert_policy.alert_policy,
│ on google.tf line 1, in resource "google_monitoring_alert_policy""alert_policy":
│ 1: resource"google_monitoring_alert_policy""alert_policy" {
│
This error is caused by terraform completes documentation.0.mime_type = "text/markdown" automatically.
Description
From my understanding,
The mime_type is required for content, but not for subject.
There are no dependencies between content and subject.
So I think the completion is not necessary in this case.
How do you think about adding the condition that mime_type is only completed when the content is set?
According to terraform registry the documentation blockcontent, mime_type and subject are optional. But when we are attempting to create the google_monitoring_alert_policy it triggers the next error:
Error creating AlertPolicy: googleapi: Error 400: Request was missing field alert_policy.documentation.mime_type: non-empty content requires non-empty MIME type and vice versa.
Community Note
Terraform Version & Provider Version(s)
Affected Resource(s)
google_monitoring_alert_policy
Terraform Configuration
Add
documentation.0.subject = "baz"
to Example Usage - Monitoring Alert Policy Basic.Debug Output
No response
Expected Behavior
Create a resource successfully when run
terraform apply
.Actual Behavior
terraform apply
fails because API returns status code400
as follows:This error is caused by
terraform
completesdocumentation.0.mime_type = "text/markdown"
automatically.Description
From my understanding,
mime_type
is required forcontent
, but not forsubject
.content
andsubject
.So I think the completion is not necessary in this case.
How do you think about adding the condition that
mime_type
is only completed when thecontent
is set?Workaround
Set
mime_type = ""
.<snip> documentation { + mime_type = "" subject = "baz" } }
Steps to reproduce
terraform apply
Important Factoids
No response
References
subject
was added in following PR later thancontent
andmime_type
.Added Subject Field to Alert Policy Monitoring Resource GoogleCloudPlatform/magic-modules#9360
b/349152014
The text was updated successfully, but these errors were encountered: