Skip to content

Commit

Permalink
feat: new sentry_integration_pagerduty resource (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed May 6, 2024
1 parent 6df3529 commit 99fb59f
Show file tree
Hide file tree
Showing 9 changed files with 605 additions and 1 deletion.
58 changes: 58 additions & 0 deletions docs/resources/integration_pagerduty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sentry_integration_pagerduty Resource - terraform-provider-sentry"
subcategory: ""
description: |-
Manage a PagerDuty service integration.
---

# sentry_integration_pagerduty (Resource)

Manage a PagerDuty service integration.

## Example Usage

```terraform
# Retrieve the PagerDuty organization integration
data "sentry_organization_integration" "pagerduty" {
organization = local.organization
provider_key = "pagerduty"
name = "my-pagerduty-organization"
}
# Associate a PagerDuty service and integration key with a Sentry PagerDuty integration
resource "sentry_integration_pagerduty" "test" {
organization = local.organization
integration_id = data.sentry_organization_integration.pagerduty.id
service = "my-pagerduty-service"
integration_key = "my-pagerduty-integration-key"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `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.
- `integration_key` (String) The integration key of the PagerDuty service.
- `organization` (String) The slug of the organization the resource belongs to.
- `service` (String) The name of the PagerDuty service.

### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
# import using the organization slug from the URL:
# https://sentry.io/api/0/organizations/[org-slug]/integrations/
# [integration-id] is the top-level `id` of the PagerDuty organization integration
# [service-id] is the `id` of the service_table record to import under the configData property
terraform import sentry_integration_pagerduty.default org-slug/integration-id/service-id
```
5 changes: 5 additions & 0 deletions examples/resources/sentry_integration_pagerduty/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# import using the organization slug from the URL:
# https://sentry.io/api/0/organizations/[org-slug]/integrations/
# [integration-id] is the top-level `id` of the PagerDuty organization integration
# [service-id] is the `id` of the service_table record to import under the configData property
terraform import sentry_integration_pagerduty.default org-slug/integration-id/service-id
16 changes: 16 additions & 0 deletions examples/resources/sentry_integration_pagerduty/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Retrieve the PagerDuty organization integration
data "sentry_organization_integration" "pagerduty" {
organization = local.organization

provider_key = "pagerduty"
name = "my-pagerduty-organization"
}

# Associate a PagerDuty service and integration key with a Sentry PagerDuty integration
resource "sentry_integration_pagerduty" "test" {
organization = local.organization
integration_id = data.sentry_organization_integration.pagerduty.id

service = "my-pagerduty-service"
integration_key = "my-pagerduty-integration-key"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad
golang.org/x/oauth2 v0.20.0
golang.org/x/sync v0.7.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgf
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13 h1:eZa5D/JOnxQpWTEJ89SCKtiCVZLTl8vagCe6mduTpZA=
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505023158-b33f9fa02d13/go.mod h1:ZMSSWRuXbIwtoH4jg2ka9ZA8x3o3zC8nkTeeqq97G7g=
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad h1:EDHZoO16MSxoKUi2XDZPSyiMSuTdbGNUqCKJYAYsh5Y=
github.com/jianyuan/go-sentry/v2 v2.7.1-0.20240505225549-2092363c6dad/go.mod h1:ZMSSWRuXbIwtoH4jg2ka9ZA8x3o3zC8nkTeeqq97G7g=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand Down
3 changes: 3 additions & 0 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ var (
// TestOrganization is the organization used for acceptance tests.
TestOrganization = os.Getenv("SENTRY_TEST_ORGANIZATION")

// TestPagerDutyOrganization is the PagerDuty organization used for acceptance tests.
TestPagerDutyOrganization = os.Getenv("SENTRY_TEST_PAGERDUTY_ORGANIZATION")

// SharedClient is a shared Sentry client for acceptance tests.
SharedClient *sentry.Client
)
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (p *SentryProvider) Resources(ctx context.Context) []func() resource.Resour
return []func() resource.Resource{
NewAllProjectsSpikeProtectionResource,
NewClientKeyResource,
NewIntegrationPagerDuty,
NewIssueAlertResource,
NewNotificationActionResource,
NewProjectInboundDataFilterResource,
Expand Down
Loading

0 comments on commit 99fb59f

Please sign in to comment.