Skip to content

Commit

Permalink
Follow the shape of the resource definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed Jan 19, 2023
1 parent 1e66be7 commit 0050656
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 113 deletions.
73 changes: 51 additions & 22 deletions docs/resources/issue_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,101 +23,131 @@ resource "sentry_issue_alert" "main" {
frequency = 30
conditions = [
# A new issue is created
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
name = "A new issue is created"
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},
# The issue changes state from resolved to unresolved
{
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
name = "The issue changes state from resolved to unresolved"
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
},
# The issue is seen more than 100 times in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
name = "The issue is seen more than 100 times in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},
# The issue is seen by more than 100 users in 1h
{
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
name = "The issue is seen by more than 100 users in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},
# The issue affects more than 50.0 percent of sessions in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
name = "The issue affects more than 50.0 percent of sessions in 1h"
value = 50.0
comparisonType = "count"
interval = "1h"
},
]
filters = [
# The issue is older than 10 minute
{
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
name = "The issue is older than 10 minute"
value = 10
time = "minute"
comparison_type = "older"
},
# The issue has happened at least 10 times
{
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
name = "The issue has happened at least 10 times"
value = 10
},
# The issue is assigned to Team
{
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
name = "The issue is assigned to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},
# The event is from the latest release
{
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
name = "The event is from the latest release"
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
},
# The event's message value contains test
{
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
name = "The event's message value contains test"
attribute = "message"
match = "co"
value = "test"
},
# The event's tags match test contains test
{
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
name = "The event's tags match test contains test"
key = "test"
match = "co"
value = "test"
},
# The event's level is equal to fatal
{
id = "sentry.rules.filters.level.LevelFilter"
name = "The event's level is equal to fatal"
match = "eq"
level = "50"
}
]
actions = [
# Send a notification to IssueOwners
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to IssueOwners"
targetType = "IssueOwners"
targetIdentifier = ""
},
# Send a notification to Team
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},
# Send a notification (for all legacy integrations)
{
id = "sentry.rules.actions.notify_event.NotifyEventAction"
name = "Send a notification (for all legacy integrations)"
}
id = "sentry.rules.actions.notify_event.NotifyEventAction"
},
# Send a notification to the Slack workspace to #general
{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#general"
# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
# Or use the sentry_organization_integration data source to retrieve the integration ID:
workspace = data.sentry_organization_integration.slack.internal_id
},
]
}
# Retrieve a Slack integration
data "sentry_organization_integration" "slack" {
organization = sentry_project.test.organization
provider_key = "slack"
name = "Slack Workspace" # Name of your Slack workspace
}
```

<!-- schema generated by tfplugindocs -->
Expand Down Expand Up @@ -151,7 +181,6 @@ Import is supported using the following syntax:

```shell
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/[project-slug]/[rule-id]/details/
terraform import sentry_issue_alert.default org-slug/project-slug/rule-id
```
2 changes: 2 additions & 0 deletions docs/resources/metric_alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ Import is supported using the following syntax:
# import using the organization, project slugs and rule id from the URL:
# https://sentry.io/organizations/[org-slug]/projects/[project-slug]/
# https://sentry.io/organizations/[org-slug]/alerts/rules/details/[rule-id]/
# or
# https://sentry.io/organizations/[org-slug]/alerts/metric-rules/[project-slug]/[rule-id]/
terraform import sentry_metric_alert.default org-slug/project-slug/rule-id
```
70 changes: 50 additions & 20 deletions examples/resources/sentry_issue_alert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,98 +8,128 @@ resource "sentry_issue_alert" "main" {
frequency = 30

conditions = [
# A new issue is created
{
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
name = "A new issue is created"
id = "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
},

# The issue changes state from resolved to unresolved
{
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
name = "The issue changes state from resolved to unresolved"
id = "sentry.rules.conditions.regression_event.RegressionEventCondition"
},

# The issue is seen more than 100 times in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
name = "The issue is seen more than 100 times in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue is seen by more than 100 users in 1h
{
id = "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
name = "The issue is seen by more than 100 users in 1h"
value = 100
comparisonType = "count"
interval = "1h"
},

# The issue affects more than 50.0 percent of sessions in 1h
{
id = "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
name = "The issue affects more than 50.0 percent of sessions in 1h"
value = 50.0
comparisonType = "count"
interval = "1h"
},
]

filters = [
# The issue is older than 10 minute
{
id = "sentry.rules.filters.age_comparison.AgeComparisonFilter"
name = "The issue is older than 10 minute"
value = 10
time = "minute"
comparison_type = "older"
},

# The issue has happened at least 10 times
{
id = "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter"
name = "The issue has happened at least 10 times"
value = 10
},

# The issue is assigned to Team
{
id = "sentry.rules.filters.assigned_to.AssignedToFilter"
name = "The issue is assigned to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# The event is from the latest release
{
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
name = "The event is from the latest release"
id = "sentry.rules.filters.latest_release.LatestReleaseFilter"
},

# The event's message value contains test
{
id = "sentry.rules.filters.event_attribute.EventAttributeFilter"
name = "The event's message value contains test"
attribute = "message"
match = "co"
value = "test"
},

# The event's tags match test contains test
{
id = "sentry.rules.filters.tagged_event.TaggedEventFilter"
name = "The event's tags match test contains test"
key = "test"
match = "co"
value = "test"
},

# The event's level is equal to fatal
{
id = "sentry.rules.filters.level.LevelFilter"
name = "The event's level is equal to fatal"
match = "eq"
level = "50"
}
]

actions = [
# Send a notification to IssueOwners
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to IssueOwners"
targetType = "IssueOwners"
targetIdentifier = ""
},

# Send a notification to Team
{
id = "sentry.mail.actions.NotifyEmailAction"
name = "Send a notification to Team"
targetType = "Team"
targetIdentifier = sentry_team.main.team_id
},

# Send a notification (for all legacy integrations)
{
id = "sentry.rules.actions.notify_event.NotifyEventAction"
name = "Send a notification (for all legacy integrations)"
}
id = "sentry.rules.actions.notify_event.NotifyEventAction"
},

# Send a notification to the Slack workspace to #general
{
id = "sentry.integrations.slack.notify_action.SlackNotifyServiceAction"
channel = "#general"

# From: https://sentry.io/settings/[org-slug]/integrations/slack/[slack-integration-id]/
# Or use the sentry_organization_integration data source to retrieve the integration ID:
workspace = data.sentry_organization_integration.slack.internal_id
},
]
}

# Retrieve a Slack integration
data "sentry_organization_integration" "slack" {
organization = sentry_project.test.organization

provider_key = "slack"
name = "Slack Workspace" # Name of your Slack workspace
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/jianyuan/terraform-provider-sentry
go 1.19

require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.2
github.com/hashicorp/terraform-plugin-docs v0.13.0
Expand Down Expand Up @@ -32,7 +33,6 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.3.1 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
Expand Down
14 changes: 1 addition & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.4.6 h1:MDV3UrKQBM3du3G7MApDGvOsMYy3JQJ4exhSoKBAeVA=
github.com/hashicorp/go-plugin v1.4.6/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ=
github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
Expand Down Expand Up @@ -136,8 +134,6 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE=
github.com/jianyuan/go-sentry/v2 v2.1.1 h1:vBYdRvRouHOyyAhl9s7l8x8s0O51plUV+q9+vUdpvLg=
github.com/jianyuan/go-sentry/v2 v2.1.1/go.mod h1:OZZZB/l6QO4g1qzLWiW4wu6KvOBSmebOnskOr4Uc99o=
github.com/jianyuan/go-sentry/v2 v2.2.0 h1:yAJxTjEBFLh/3ED8n4XiheaeadPaeBuMr8owTq1ZUJE=
github.com/jianyuan/go-sentry/v2 v2.2.0/go.mod h1:OZZZB/l6QO4g1qzLWiW4wu6KvOBSmebOnskOr4Uc99o=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
Expand Down Expand Up @@ -250,13 +246,9 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk=
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.3.0 h1:6l90koy8/LaBLmLu8jpHeHexzMwEita0zFfYlggy2F8=
golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -280,18 +272,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
Loading

0 comments on commit 0050656

Please sign in to comment.