terraform-provider-sentry
terraform-provider-sentry copied to clipboard
Slack notification rule: map[actions:[Ensure at least one action is enabled and all required fields are filled in.]]
Hi!
I've been trying to create new rule for the project via terraform resource
resource "sentry_plugin" "slack" {
organization = sentry_project.this.organization
project = sentry_project.this.name
plugin = "slack"
config = {
webhook = "https://hooks.slack.com/services/****/****"
channel = "#sentry"
}
}
resource "sentry_rule" "slack" {
organization = sentry_project.this.organization
project = sentry_project.this.name
action_match = "all"
frequency = 5
name = "slack"
actions = [{
id = "sentry.rules.actions.notify_event_service.NotifyEventServiceAction"
service = "slack"
}]
conditions = [{
id = "sentry.rules.conditions.every_event.EveryEventCondition"
}]
}
Please find below that for rule parameters I have used the exact payload from rule creation in UI to make sure I won't miss anything:
To my surprise it did not work, the following error was thrown:
Error: sentry: map[actions:[Ensure at least one action is enabled and all required fields are filled in.]]
on main.tf line 177, in resource "sentry_rule" "slack":
177: resource "sentry_rule" "slack" {
Could you please assist me in figuring out whether it is my mistake or the provider issue?
Thank you.
If you use the latest sentry plugin working with workspace, I suggest you to use
sentry.integrations.slack.notify_action.SlackNotifyServiceAction
Here is a example:
resource "sentry_rule" "slack" {
organization = sentry_project.this.organization
project = sentry_project.this.name
action_match = "all"
frequency = 5
name = "slack"
actions = [{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
channel = "#sentry,
workspace = "000000"
}]
conditions = [{
id = "sentry.rules.conditions.every_event.EveryEventCondition"
}]
}
@mced, is there a solution for legacy plugin?
As I don't use it anymore I can't help you. However you can search and found the json response which contains what you're looking for from the sentry page when posting the rule.
Thanks for the tip.
I did the same exercise with response values but bumped into the same error.
resource "sentry_rule" "slack" {
organization = sentry_project.this.organization
project = sentry_project.this.name
action_match = "all"
frequency = 30
name = "slack"
actions = [{
enabled = true
id = "sentry.rules.actions.notify_event_service.NotifyEventServiceAction"
service = "slack"
name = "Send a notification via slack"
label = "Send a notification via {service}"
}]
conditions = [{
id = "sentry.rules.conditions.every_event.EveryEventCondition"
name = "An event is seen"
}]
}
I believe that enabled
seem to be this missed required parameter (Error: sentry: map[actions:[Ensure at least one action is enabled and all required fields are filled in.]])
However, I've noticed that action map values are being converted to strings on apply (including boolean enabled
). Can't this cause the issue?
Terraform will perform the following actions:
# sentry_rule.slack will be created
+ resource "sentry_rule" "slack" {
+ action_match = "all"
+ actions = [
+ {
+ "enabled" = "true"
+ "id" = "sentry.rules.actions.notify_event_service.NotifyEventServiceAction"
+ "label" = "Send a notification via {service}"
+ "name" = "Send a notification via slack"
+ "service" = "slack"
},
]
+ conditions = [
+ {
+ "id" = "sentry.rules.conditions.every_event.EveryEventCondition"
+ "name" = "An event is seen"
},
]
+ environment = (known after apply)
+ frequency = 30
+ id = (known after apply)
+ name = "***"
+ organization = "***"
+ project = "***
}
I've created the sentry_rule
resource, I will have a look into that! Thanks for reporting 👍
@PavelMikhailouski I've investigated and it is not related to the Terraform
resource AT ALL.
I got it working with the below:
resource "sentry_rule" "slack" {
organization = sentry_project.this.organization
project = sentry_project.this.name
name = "Slack"
action_match = "any"
frequency = 30
actions = [{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#sentry"
name = "Send a notification via slack"
label = "Send a slack notification"
workspace = "XXXX"
tags = "environment"
}]
conditions = [{
id = "sentry.rules.conditions.every_event.EveryEventCondition"
}]
}
You can get your own workspace
value by going to configuration
URL of Slack integration on Sentry
admin.
Example https://sentry.io/settings/XXX/integrations/slack/XXXX/
Thanks @chreble! As far as I can judge your solution works for the latest plugin version.
Is there something we can to to make rules work with legacy one?
What would be really nice would to be able to do a data lookup to get the workspace value
Would really be nice if this worked with legacy plugins as it looks like Sentry still makes heavy use of them for certain plugins, such as opsgenie. When creating a rule on the website, they only send over the action id=sentry.rules.actions.notify_event_service.NotifyEventServiceAction
and service=opsgenie
. When I follow the same format with this provider it still returns Error: sentry: map[actions:[Ensure all required fields are filled in.]]
Would really be nice if this worked with legacy plugins as it looks like Sentry still makes heavy use of them for certain plugins, such as opsgenie. When creating a rule on the website, they only send over the action
id=sentry.rules.actions.notify_event_service.NotifyEventServiceAction
andservice=opsgenie
. When I follow the same format with this provider it still returnsError: sentry: map[actions:[Ensure all required fields are filled in.]]
@CodechCFA I'm getting the same error. Did you manage to find a work around?
@AnitaErnszt we did not unfortunately. We use terraform to create the plugin but not any rules.
I'm going to close this since it's likely fixed in the latest version.