Terraform provider for Sentry.
See the the Provider Configuration page of the Terraform documentation for instructions.
Pre-compiled binaries are available from the Releases page.
# Configure the Sentry Provider
provider "sentry" {
token = var.sentry_token
base_url = var.sentry_base_url
}
The following arguments are supported:
token
- (Required) This is the Sentry authentication token. The value can be sourced from theSENTRY_TOKEN
environment variable.base_url
- (Optional) This is the target Sentry base API endpoint. The default value ishttps://app.getsentry.com/api/
. The value must be provided when working with Sentry On-Premise. The value can be sourced from theSENTRY_BASE_URL
environment variable.
# Create an organization
resource "sentry_organization" "default" {
name = "My Organization"
slug = "my-organization"
agree_terms = true
}
The following arguments are supported:
name
- (Required) The human readable name for the organization.slug
- (Optional) The unique URL slug for this organization. If this is not provided a slug is automatically generated based on the name.agree_terms
- (Required) You agree to the applicable terms of service and privacy policy.
The following attributes are exported:
id
- The ID of the created organization.
# Create a team
resource "sentry_team" "default" {
organization = "my-organization"
name = "My Team"
slug = "my-team"
}
The following arguments are supported:
organization
- (Required) The slug of the organization the team should be created for.name
- (Required) The human readable name for the team.slug
- (Optional) The unique URL slug for this team. If this is not provided a slug is automatically generated based on the name.
The following attributes are exported:
id
- The ID of the created team.
# Create a project
resource "sentry_project" "default" {
organization = "my-organization"
team = "my-team"
name = "Web App"
slug = "web-app"
platform = "javascript"
}
The following arguments are supported:
organization
- (Required) The slug of the organization the project should be created for.team
- (Required) The slug of the team the project should be created for.name
- (Required) The human readable name for the project.slug
- (Optional) The unique URL slug for this project. If this is not provided a slug is automatically generated based on the name.platform
- (Optional) The integration platform.
The following attributes are exported:
id
- The ID of the created project.
# Create a key
resource "sentry_key" "default" {
organization = "my-organization"
project = "web-app"
name = "My Key"
}
The following arguments are supported:
organization
- (Required) The slug of the organization the key should be created for.project
- (Required) The slug of the project the key should be created for.name
- (Required) The name of the key.
The following attributes are exported:
id
- The ID of the created key.public
- Public key portion of the client key.secret
- Secret key portion of the client key.project_id
- The ID of the project that the key belongs to.is_active
- Flag indicating the key is active.rate_limit_window
- Length of time that will be considered when checking the rate limit.rate_limit_count
- Number of events that can be reported within the rate limit window.dsn_secret
- DSN (Deprecated) for the key.dsn_public
- DSN for the key.dsn_csp
- DSN for the Content Security Policy (CSP) for the key.
# Create a plugin
resource "sentry_plugin" "default" {
organization = "my-organization"
project = "web-app"
plugin = "slack"
config = {
webhook = "slack://webhook"
}
}
The following arguments are supported:
organization
- (Required) The slug of the organization the plugin should be enabled for.project
- (Required) The slug of the project the plugin should be enabled for.plugin
- (Required) Identifier of the plugin.config
- (Optional) Configuration of the plugin.
The following attributes are exported:
id
- The ID of the created plugin.
# Create a plugin
resource "sentry_rule" "default" {
organization = "my-organization"
project = "web-app"
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 = "12345"
}
]
}
The following arguments are supported:
organization
- (Required) The slug of the organization the plugin should be enabled for.project
- (Required) The slug of the project the plugin should be enabled for.action_match
- (Optional) Useall
to trigger alerting when all conditions are met, andany
when at least a condition is met. Defaults toany
.frequency
- (Optional) Perform actions at most once everyX
minutes for this issue. Defaults to30
.environment
- (Optional) Environment nameactions
- (Required) List of actionsconditions
- (Required) List of conditions
The following attributes are exported:
id
- The ID of the created rule.name
- The name of the created rule.actions
- The rule's actions.conditions
- The rule's conditions.frequency
- The rule's frequency.environment
- The rule's environment.
# Retrieve the Default Key
data "sentry_key" "default" {
organization = "my-organization"
project = "web-app"
name = "Default"
}
The following arguments are supported:
organization
- (Required) The slug of the organization the key should be created for.project
- (Required) The slug of the project the key should be created for.name
- (Optional) The name of the key to retrieve.first
- (Optional) Boolean flag indicating that we want the first key of the returned keys.
The following attributes are exported:
id
- The ID of the created key.public
- Public key portion of the client key.secret
- Secret key portion of the client key.project_id
- The ID of the project that the key belongs to.is_active
- Flag indicating the key is active.rate_limit_window
- Length of time that will be considered when checking the rate limit.rate_limit_count
- Number of events that can be reported within the rate limit window.dsn_secret
- DSN (Deprecated) for the key.dsn_public
- DSN for the key.dsn_csp
- DSN for the Content Security Policy (CSP) for the key.
You can import existing resources using the terraform import
command.
To import an organization:
$ terraform import sentry_organization.default org-slug
To import a team:
$ terraform import sentry_team.default org-slug/team-slug
To import a project:
$ terraform import sentry_project.default org-slug/project-slug
Test the provider by running make test
.
Make sure to set the following environment variables:
SENTRY_TEST_ORGANIZATION
SENTRY_TOKEN
See the Writing Custom Providers page of the Terraform documentation for instructions.