jianyuan / terraform-provider-sentry Goto Github PK
View Code? Open in Web Editor NEWTerraform provider for Sentry
Home Page: https://registry.terraform.io/providers/jianyuan/sentry/latest
License: MIT License
Terraform provider for Sentry
Home Page: https://registry.terraform.io/providers/jianyuan/sentry/latest
License: MIT License
The following rule fails validation:
resource "sentry_rule" "default" {
depends_on = [sentry_project.default]
organization = var.organization
project = var.app_name
name = "Send a notification for new events"
action_match = "any"
frequency = 60
conditions = [
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},
{
id = "sentry.rules.conditions.regression_event.RegressionEventCondition",
},
{
id = "sentry.rules.conditions.reappeared_event.ReappearedEventCondition"
},
{
interval = "1h"
value = "1"
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
}
]
actions = [
{
id = "sentry.mail.actions.NotifyEmailAction"
target_type = "IssueOwners"
target_identifier = ""
},
{
name = "Send a notification to the Lightmatter Slack workspace to #${var.app_name}-internal and show tags [] in notification"
workspace = var.slack_workspace_id
tags = "environment"
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#${var.app_name}-internal"
}
]
}
With sentry: map[actions:[Ensure at least one action is enabled and all required fields are filled in.] conditions:[Ensure at least one action is enabled and all required fields are filled in.]
Removing the EventUniqueUserFrequencyCondition and NotifyEmailAction will fix the issue.
It's worth mentioning that the condition given in the documentation EG:
conditions = [
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
value = 500
interval = "1h"
}
]
Will trigger the condition error as well.
Output from terraform 0.12checklist:
- [ ] Provider "sentry" may need to be upgraded to a newer version that supports Terraform 0.12. (Supported version information is not available for this provider.)
It'd be great if we could also create a sentry key for a project during creation, in order to provide it in an output.
They provide APIs to create/list/delete keys:
I suppose this would probably be it's own resource rather than being part of the project.
What it says on the tin. It would be lovely to see this provider level up in the Registry. :) Link: https://registry.terraform.io/modules/jianyuan/sentry/provider/0.4.0. Cheers!
Hi,
seems for me, that sentry_rule
resource can manage only alert rules classified as "Issues" (Alerts->myproject->Select Alert->Issues). The rest, such as "Number of Errors", "Users Experiencing Errors",... have different structure of payloads ("type": "alert_rule"
VS "type": "rule"
, etc).
Is it possible to manage these types of alerts with terraform?
Thank you
I've just finished importing all of our existing sentry projects, and did prod last. I have a bunch of our prod projects starred (bookmarked in sentry API terms). It appears that this has put things in a state where a diff is always showing up when I plan. It looks like the value is updated when I apply, but it's still there on the next plan:
$ make plan app=accounting
~ module.sentry_project.sentry_project.default
is_bookmarked: "true" => "false"
Plan: 0 to add, 1 to change, 0 to destroy.
$ make apply app=accounting
module.sentry_project.sentry_project.default: Modifying... (ID: prod-accounting)
is_bookmarked: "true" => "false"
module.sentry_project.sentry_project.default: Modifications complete after 0s (ID: prod-accounting)
$ make plan app=accounting
~ module.sentry_project.sentry_project.default
is_bookmarked: "true" => "false"
Plan: 0 to add, 1 to change, 0 to destroy.
The following sentry_rule
condition returns a validation error.
conditions = [
{
id = "sentry.rules.conditions.tagged_event.TaggedEventCondition"
key = "environment"
match = "eq"
value = "staging"
}
]
Error: sentry: map[conditions:[Ensure at least one action is enabled and all required fields are filled in.]]
It looks like the underlying sentry client library doesn't support the match
attribute, is that right?
I have no idea if this refers to Apache Sentry or something else. Perhaps provide a link to what Sentry is in the README?
Terraform expects a specific naming scheme to be used for the binary. This is outlined here in their Docs. When extracting the Sentry provider, the filename is missing the SemVer suffix. It should be suffixed with _v0.5.2
in this case.
$ wget https://github.com/jianyuan/terraform-provider-sentry/releases/download/v0.5.2/terraform-provider-sentry_0.5.2_linux_amd64.tar.gz
$ tar -C ./plugins -zxvf terraform-provider-sentry_0.5.2_linux_amd64.tar.gz
$ ls -luah plugins/
total 31M
drwxr-xr-x 2 root root 4.0K Dec 10 14:51 .
drwxr-xr-x 3 root root 4.0K Dec 10 14:49 ..
-rw-r--r-- 1 501 staff 1.1K Dec 10 14:52 LICENSE
-rw-r--r-- 1 501 staff 7.4K Dec 10 14:53 README.md
-rwxr-xr-x 1 501 staff 23M Dec 10 14:52 terraform-provider-sentry
$ wget https://github.com/jianyuan/terraform-provider-sentry/releases/download/v0.5.2/terraform-provider-sentry_0.5.2_linux_amd64.tar.gz
$ tar -C ./plugins -zxvf terraform-provider-sentry_0.5.2_linux_amd64.tar.gz
$ ls -luah plugins/
total 31M
drwxr-xr-x 2 root root 4.0K Dec 10 14:51 .
drwxr-xr-x 3 root root 4.0K Dec 10 14:49 ..
-rwxr-xr-x 1 501 staff 23M Dec 10 14:52 terraform-provider-sentry_v0.5.2
is there a way currently to add more than 1 team to a project?
Hi! First I want to say thank you for making this Terraform provider!
Would it be possible to add support for metric alerts. This new alert type does not use the same schema as the issue alerts currently supported by the provider.
https://docs.sentry.io/product/alerts/alert-types/#metric-alerts
https://docs.sentry.io/product/alerts/create-alerts/metric-alert-config/
Thanks!
After creating my rule, I attempt to update it w/ this plan:
action_match = "any"
actions = [
{
"channel" = "#sampleapp-internal"
"id" = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
"name" = "Send a notification to the mycorp Slack workspace to #sampleapp-internal and show tags [] in notification"
"tags" = "environment"
"workspace" = "xxx"
},
]
conditions = [
{
"id" = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},
{
"id" = "sentry.rules.conditions.regression_event.RegressionEventCondition"
},
{
"id" = "sentry.rules.conditions.reappeared_event.ReappearedEventCondition"
},
]
~ frequency = 30 -> 60
id = "xxxx"
name = "Send a notification for new events"
organization = "myorg"
project = "sampleapp"
}
gives this result:
Error: sentry: map[environment:[This field may not be blank.]]
Hello, is there any documentation on what auth token scopes are required by the provider ?
I'm about to test this and when I'm creating the auth token I'm required to check the scopes:
Thanks
Hello @jianyuan
I tried to create Rule, but I faced with problem and issue
My resource:
resource "sentry_rule" "default" {
organization = data.terraform_remote_state.org.outputs.slug
name = "Rule Name"
project = "myProject"
action_match = "any"
frequency = 30
environment = "production"
conditions = [
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
value = 500
interval = "1h"
}
]
actions = [
{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#alerts"
workspace = "SlackWorkSpace"
tags = "asd"
}
]
}
After terraform apply
i received
Error: sentry: map[detail:Internal Error errorId:5c08e2d28846472197e92d0c51f071e0]
on main.tf line 14, in resource "sentry_rule" "default":
14: resource "sentry_rule" "default" {
Looks like workspace
cannot be fetched cleaned_data
Could you fix it?
When you create a project, a key is created automatically behind the scenes by Sentry. In order to reference a sentry key in a declarative way, one must create a duplicate key for that project separately.
resource "sentry_project" "default" {
organization = sentry_org.default.slug
team = sentry_team.default.slug
name = "default project"
}
resource "sentry_key" "default" {
organization = sentry_org.default.slug
project = sentry_project.default.slug
name = "default"
}
This will result in two keys defined on the project, though. You could use a data
source, but that will fail until the project and key are created (i.e. we need a way to break the cycle, or do something like the above and pollute the keys for a project).
I would like to introduce a new bool project resource parameter, remove_default_key
, that removes the default project key when creating a project. It's similar in semantic meaning to the remove_default_node_pool parameter on the Terraform Google Cluster resource. The default value would be false.
Then, this would yield only a single key:
resource "sentry_project" "default" {
organization = sentry_org.default.slug
team = sentry_team.default.slug
name = "default project"
remove_default_key = true
}
resource "sentry_key" "default" {
organization = sentry_org.default.slug
project = sentry_project.default.slug
name = "default"
}
Is that reasonable? I wanted to open an issue to discuss before diving in to the code.
I'm trying to update the name of a rule already created.
And now I'm facing this issue.
Error: sentry: map[environment:[This field may not be blank.]]
Here is the snippet:
resource "sentry_rule" "rule" {
organization = "organization"
project = "project"
name = "Managed by Terraform"
action_match = "any"
frequency = 30
environment = null
actions = [{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
channel = "#errors",
tags = "environment",
workspace = "xxxxx"
}]
conditions = [{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
}, {
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
}]
}
I'd like a rule that triggers on all environments.
Terraform has recently introduced a standalone SDK for plugin development. Migrate this project to use the standalone SDK.
The below configuration keeps issuing a changed state.
The resource is configured properly in Sentry though.
# Create a plugin
resource "sentry_plugin" "default" {
organization = "my-organization"
project = "web-app"
plugin = "pagerduty"
config = {
service_key = "pagerduty_key"
}
}
Terraform will perform the following actions:
~ sentry_plugin.default
config.service_key: "" => "pagerduty_key"
Error: invalid character '<' looking for beginning of value
on sentry.tf line 13, in resource "sentry_team" "test":
13: resource "sentry_team" "test" {
This error occurs when missing the /api/
suffix to the Base URL. I know the Docs give an example base_url
but I interpreted "base url" as the base url to my Sentry installation at first.
Maybe add this to the Docs or have the Provider first check the URL if it is valid and return a more meaningful error?
๐ Hi, I'm on the Terraform Providers team at HashiCorp. With the release of the Terraform 0.13 beta, users can now download and install community providers from the registry. We are inviting provider authors (especially those for popular community providers) to publish their providers in a closed beta.
To get invited to the closed beta, please email [email protected]. We need:
You can use one key for all of your providers, or separate keys if you prefer. If you are publishing from an organization, this key or keys will be associated with that namespace. Once in the beta, you can manage personal keys in the UI as well.
For some reason when adding a new project, the platform is not set in Sentry. I have to run terraform apply
a second time, only then the platform is added.
Any ideas?
What is the 2021 roadmap ?
Do you plan to implement lots of new resources ?
I have a *.tf
file with a sentry_team
resource.
After creating the team using terraform, If I use a SENTRY_TOKEN with no permission to read teams, then the provider assumes the team doesn't exist and wants to create a new one.
Took me a while to figure out that the problem was a permissions scope thing. I'd expected the provider to output something like a 403 error instead of silently failing.
I am trying to setup rules but seems like filters
aren't supported.
Following is one of the alert-rule setup manually on sentry. conditions
and actions
are available with the provider but not filters, or may be I am missing something?
{
"actionMatch": "all",
"filters": [
{
"name": "The event's level is greater than or equal to error",
"id": "sentry.rules.filters.level.LevelFilter",
"match": "gte",
"level": "40"
},
{
"attribute": "stacktrace.filename",
"value": "static_data_service.py",
"id": "sentry.rules.filters.event_attribute.EventAttributeFilter",
"match": "nc",
"name": "The event's stacktrace.filename value does not contain static_data_service.py"
}
],
"actions": [
{
"name": "Send a notification to the workspace to and show tags [] in notification",
"tags": "",
"channel_id": "******",,
"workspace": "******",,
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"channel": "#team-backend"
}
],
"dateCreated": "2019-12-18T22:41:06.744971Z",
"frequency": 30,
"createdBy": null,
"id": "******",
"projects": [
"backend"
],
"name": "Pager worthy alerts",
"type": "rule",
"environment": "prod",
"filterMatch": "all",
"conditions": [
{
"interval": "1m",
"name": "The issue is seen more than 10 times in 1m",
"value": 10,
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
}
]
}
Upstream uses SENTRY_AUTH_TOKEN
as per https://docs.sentry.io/product/cli/configuration/#to-authenticate-manually.
It would make sense to align.
Getting random error when trying to rule the following rule with pagerduty integration. Running Terraform 0.14
Error: sentry: map[detail:Internal Error errorId:92d153b93ba24161bfa07c22e7db5c50]
resource "sentry_rule" "pagerduty" {
organization = "company
project = "test"
action_match = "any"
frequency = "1d"
name = "PagerDuty rule"
conditions = [
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
name = "A new issue is created"
},
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
value = "1"
interval = "1d"
}
]
filters = []
actions = [
{
id = "sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction"
account = [Retrieved from url of pagerduty integration. https://sentry.io/settings/coalition-inc/integrations/pagerduty/XXXX/]
service = [Name of Service under pagerduty integration settings]
}
]
}
I'm trying to create a new rule using this plugin but it keeps throwing below error:
# sentry_rule.rule-name will be created
+ resource "sentry_rule" "rule-name" {
+ action_match = "any"
+ actions = [
+ {
+ "channel" = "#channel-name"
+ "id" = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
+ "workspace" = "workspace-name"
},
]
+ conditions = [
+ {
+ "id" = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},
]
+ environment = (known after apply)
+ frequency = 5
+ id = (known after apply)
+ name = "rule-name"
+ organization = "org-name"
+ project = "project-name"
}
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
sentry_rule.rule-name: Creating...
Error: sentry: map[detail:Internal Error errorId:6488256461364f5daf84bb90df76584c]
on main.tf line 36, in resource "sentry_rule" "rule-name":
36: resource "sentry_rule" "rule-name" {
To overcome this issue, I have created the rule manually from sentry dashboard. Post this, I did a terraform import
.
Whats weird is that when I do a terraform plan
, its finding some difference in the config and state. Hence its suggesting some changes to be applied as below:
~ resource "sentry_rule" "rule-name" {
+ action_match = "any"
+ actions = [
+ {
+ "channel" = "#channel-name"
+ "id" = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
+ "workspace" = "workspace-name"
},
]
+ conditions = [
+ {
+ "id" = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},
]
frequency = 5
id = "AXXYYZZ"
name = "rule-name"
organization = "org-name"
project = "project-name"
}
On terraform apply
, it fails with the below error:
Error: sentry: map[detail:Internal Error errorId:7388c38cefa44e8f9d2f8f94b3b61235]
on main.tf line 59, in resource "sentry_rule" "rule-name":
36: resource "sentry_rule" "rule-name" {
After this error is raised, next time onwards terraform plan
does not detect any changes!
I'm not able to understand this inconsistent behaviour. Can someone help me out here?
Hi
If an existing project (say, "web-app") is being created via the web API, it seems that it will create one with some random string suffix ("web-app9p" for example)
Do you think it would be more appropriate to retrieve
first and skip if it exists?
On the master
version of this provider (Terraform 0.12), I encountered behavior where some unknown event let to all Sentry resources disappearing from my tfstate file.
The going theory is that a problem with the Refresh/GET operation occurred on the Sentry side which instead of causing a failure caused this provider to return empty objects, leading to a success status and an empty payload.
I've seen similar behavior before when a Sentry API key is provided that doesn't have sufficient access to GET the resources from the API. Instead of erring out it succeeds and declares the resource to be non-existent, when in fact it does exist and the Provider doesn't have access to see it.
Hello! I got problem with new release 0.5.4 because it is not statically linked, like a previous one, causing problems with Alpine Linux (musl based distro)
Hey! Thanks a lot for your sentry terraform provider - great stuff. I managed to setup a team. But unfortunately I couldn't figure out how to add member to it. Reading code I couldn't find anything.
So am I right this isn't currently supported? Could you give me some hints, I'm happy to implement it!
Hello, latest release tag and master are quite different now. There is issue - #56 which resolved, but still not in release (even patch one). Is there any possibility to expect new release any time soon? Thank you!
The slack workspace command needs the ID of the integration, but I can't fetch without using the resource and specifying details such as webhook destination.
Add measurement unit for rate_limit_window
which is seconds. I'm happy to create a merge request for it.
Hello, when I run a plan to change the team for a project, i see the changes like this:
sentry_project.serviceA team: "teamA" => "teamB"
But when applying they don't affect Sentry (I cannot see the change on their side).
I have a guess that we are missing the team information on the code here:
Sorry about flooding you with issues right now - just ran across something else I haven't seen before.
I've imported a sentry project, and am now trying to do an apply to change the name to follow our convention. It's giving me an error that doesn't really indicate what the problem actually is, and I'm not sure how to figure out what might be going wrong. I've done similar changes to other projects without issue previously.
~ module.sentry_project.sentry_project.default
slug: "prod-payments-web-4e" => "prod-payments-web"
Plan: 0 to add, 1 to change, 0 to destroy.
$ make apply app=payments-web
module.sentry_project.sentry_project.default: Modifying... (ID: prod-payments-web-4e)
slug: "prod-payments-web-4e" => "prod-payments-web"
Error applying plan:
1 error(s) occurred:
* module.sentry_project.sentry_project.default: 1 error(s) occurred:
* sentry_project.default: sentry: map[detail:Internal Error errorId:56e87ac59c6d493d9040a1f3a445300c]
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Hey, not sure if you're still working on this, but I was interested in trying it out.
It'd be helpful if there were some installation instructions to help get it set up (not very familiar w/ terraform plugins).
I've used another which provided a simple make install
command, however a set of commands to run would be fine as well.
Thanks for your work on this!
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.
Sentry is great, but the barrage of emails it sends by default is less great. I'm sure many / most of us integrate with other systems e.g. ChatOps, alerting. It would be great if you would add support for integrations and webhooks.
I have obtained a sponsored Sentry.io account for this project.
It would be nice to actually communicate with a live Sentry.io server for testing purposes.
Hi,
It would be great if you could build this for darwin_arm64 for compatbility with the latest Macs.
Thanks!
resource "sentry_organization" "default" {
name = "${var.org_name}"
}
terraform apply result in:
Terraform will perform the following actions:
+ sentry_organization.default
id: <computed>
name: "XXX"
slug: <computed>
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
sentry_organization.default: Creating...
name: "" => "XXX"
slug: "" => "<computed>"
Error: Error applying plan:
1 error(s) occurred:
* sentry_organization.default: 1 error(s) occurred:
* sentry_organization.default: sentry: map[agreeTerms:[This field is required.]]
While not documented, it exists :)
https://forum.sentry.io/t/feature-request-manage-projects-alerts-via-api/5667
(In a few months once I've gotten a few things off my plate, and start actively working on a terraform project I'll be happy to contribute to this provider)
I'm just trying to start using this and... at the very vegining I only have the "sentry_organization" one, but it's not working?
on sentry_organizations.tf line 1, in resource "sentry_organization" "default":
1: resource "sentry_organization" "default" {
Code:
resource "sentry_organization" "default" {
name = "Sentry"
slug = "sentry"
agree_terms = true
}
provider "sentry" {
token = var.sentry_token
base_url = var.my_sentry_load_balancer
}
Terraform v0.14.10
+ provider registry.terraform.io/anschoewe/curl v0.1.3
+ provider registry.terraform.io/hetznercloud/hcloud v1.26.0
+ provider registry.terraform.io/jianyuan/sentry v0.6.0
Your version of Terraform is out of date! The latest version
is 0.15.3. You can update by downloading from https://www.terraform.io/downloads.html
Support importing resources, which is possible in terraform 0.7 https://www.hashicorp.com/blog/terraform-0-7.html
I'm not really sure what is required code-wise, the documentation looks a bit vague at the moment https://www.terraform.io/docs/plugins/provider.html
It would be handy to be able to output a projects DSN after it's been created through terraform. You can get this via the /keys/
endpoint, under the dsn
object.
I'm not sure how you would expose this in TF though
Hi,
I'd really appreciate binaries of the provider for Windows. Could you provide them?
Best regards,
Ben
It seems that the Sentry team name is deprecated. Now, you just need a unique slug to create and update a team. This change is reflected in their Web UI,
Relates to #67
Looks like @jianyuan has gone AWOL, issues and PRs waiting for attention for months.
Meanwhile, Terraform and Sentry are a lethal combination and surely deserve a maintained module. What's the status?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.