Skip to content

Commit 22896ae

Browse files
committed
feat: new sentry_integration_pagerduty resource (#430)
1 parent 6df3529 commit 22896ae

File tree

9 files changed

+605
-1
lines changed

9 files changed

+605
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "sentry_integration_pagerduty Resource - terraform-provider-sentry"
4+
subcategory: ""
5+
description: |-
6+
Manage a PagerDuty service integration.
7+
---
8+
9+
# sentry_integration_pagerduty (Resource)
10+
11+
Manage a PagerDuty service integration.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Retrieve the PagerDuty organization integration
17+
data "sentry_organization_integration" "pagerduty" {
18+
organization = local.organization
19+
20+
provider_key = "pagerduty"
21+
name = "my-pagerduty-organization"
22+
}
23+
24+
# Associate a PagerDuty service and integration key with a Sentry PagerDuty integration
25+
resource "sentry_integration_pagerduty" "test" {
26+
organization = local.organization
27+
integration_id = data.sentry_organization_integration.pagerduty.id
28+
29+
service_name = "my-pagerduty-service"
30+
integration_key = "my-pagerduty-integration-key"
31+
}
32+
```
33+
34+
<!-- schema generated by tfplugindocs -->
35+
## Schema
36+
37+
### Required
38+
39+
- `integration_id` (String) The ID of the PagerDuty integration. Source from the URL `https://<organization>.sentry.io/settings/integrations/pagerduty/<integration-id>/` or use the `sentry_organization_integration` data source.
40+
- `integration_key` (String) The integration key of the PagerDuty service.
41+
- `organization` (String) The slug of the organization the resource belongs to.
42+
- `service_name` (String) The name of the PagerDuty service.
43+
44+
### Read-Only
45+
46+
- `id` (String) The ID of this resource.
47+
48+
## Import
49+
50+
Import is supported using the following syntax:
51+
52+
```shell
53+
# import using the organization slug from the URL:
54+
# https://sentry.io/api/0/organizations/[org-slug]/integrations/
55+
# [integration-id] is the top-level `id` of the PagerDuty organization integration
56+
# [service-id] is the `id` of the service_table record to import under the configData property
57+
terraform import sentry_integration_pagerduty.default org-slug/integration-id/service-id
58+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# import using the organization slug from the URL:
2+
# https://sentry.io/api/0/organizations/[org-slug]/integrations/
3+
# [integration-id] is the top-level `id` of the PagerDuty organization integration
4+
# [service-id] is the `id` of the service_table record to import under the configData property
5+
terraform import sentry_integration_pagerduty.default org-slug/integration-id/service-id
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Retrieve the PagerDuty organization integration
2+
data "sentry_organization_integration" "pagerduty" {
3+
organization = local.organization
4+
5+
provider_key = "pagerduty"
6+
name = "my-pagerduty-organization"
7+
}
8+
9+
# Associate a PagerDuty service and integration key with a Sentry PagerDuty integration
10+
resource "sentry_integration_pagerduty" "test" {
11+
organization = local.organization
12+
integration_id = data.sentry_organization_integration.pagerduty.id
13+
14+
service_name = "my-pagerduty-service"
15+
integration_key = "my-pagerduty-integration-key"
16+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/terraform-plugin-log v0.9.0
1313
github.com/hashicorp/terraform-plugin-mux v0.15.0
1414
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
15-
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13
15+
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad
1616
golang.org/x/oauth2 v0.20.0
1717
golang.org/x/sync v0.7.0
1818
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgf
132132
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
133133
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13 h1:eZa5D/JOnxQpWTEJ89SCKtiCVZLTl8vagCe6mduTpZA=
134134
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13/go.mod h1:ZMSSWRuXbIwtoH4jg2ka9ZA8x3o3zC8nkTeeqq97G7g=
135+
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad h1:EDHZoO16MSxoKUi2XDZPSyiMSuTdbGNUqCKJYAYsh5Y=
136+
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad/go.mod h1:ZMSSWRuXbIwtoH4jg2ka9ZA8x3o3zC8nkTeeqq97G7g=
135137
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
136138
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
137139
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=

internal/acctest/acctest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ var (
2121
// TestOrganization is the organization used for acceptance tests.
2222
TestOrganization = os.Getenv("SENTRY_TEST_ORGANIZATION")
2323

24+
// TestPagerDutyOrganization is the PagerDuty organization used for acceptance tests.
25+
TestPagerDutyOrganization = os.Getenv("SENTRY_TEST_PAGERDUTY_ORGANIZATION")
26+
2427
// SharedClient is a shared Sentry client for acceptance tests.
2528
SharedClient *sentry.Client
2629
)

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (p *SentryProvider) Resources(ctx context.Context) []func() resource.Resour
9696
return []func() resource.Resource{
9797
NewAllProjectsSpikeProtectionResource,
9898
NewClientKeyResource,
99+
NewIntegrationPagerDuty,
99100
NewIssueAlertResource,
100101
NewNotificationActionResource,
101102
NewProjectInboundDataFilterResource,

0 commit comments

Comments
 (0)