Set up Atlassian Operations Terraform Provider
The Atlassian Operations Terraform Provider allows you to interact with Jira Service Management resources such as users, teams, escalations, and more. By defining your resources in declarative configuration files, you can easily code, edit, review, and version-control your IT operations configurations.
View the Atlassian Operations Terraform Provider repository on GitHub.
Supported resources and data sources
This provider supports the creation and management of the following resources and data sources via Terraform:
Data Sources (Read Only)
Users (excludes User Contact API)
Teams
Schedules
Resources (Read / Write - CRUD)
Teams (with or without members)
API and email-based integrations
Escalations
Schedules
Schedule rotations
Terraform cannot update team admins
Since the user who creates a team automatically becomes its admin, and the provider can only support actions currently available via the Jira Service Management Operations REST API, you cannot update team admins with Terraform.
Configure the Terraform Provider
To set up the Atlassian Operations Terraform Provider, include atlassian-operations
in the required_providers
block of your Terraform configuration. Ensure that you configure the provider with valid credentials before using it.
Required configuration parameters
The provider requires the following parameters:
cloud_id
: The simplest way to find your site's Cloud ID is throughhttps://<your-site-name>.atlassian.net/_edge/tenant_info
domain_name
- Your site's URL, e.g.,my-site-name.atlassian.net
email_address
token
- You can list your existing Atlassian API tokens or create new ones by managing API token for your Atlassian account.
Sample configuration
Below is an example Terraform configuration:
terraform {
required_providers {
atlassian-operations = {
source = "registry.terraform.io/atlassian/atlassian-operations"
}
}
}
provider "atlassian-operations" {
cloud_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
domain_name = "xxxx.atlassian.net"
email_address = "email@example.com"
token = "<YOUR_TOKEN_HERE>"
}
For more details, visit Atlassian Operations provider page and view the documentation to explore available resources. You can find them listed on the left menu of the documentation page. Currently, the provider supports six resources and three data sources.
To get started with Terraform using this provider, refer to the Terraform tutorials.
Using Data Sources
User Data Source
To fetch a user, you need to provide an email address
.
# Get Atlassian User by email address
data "atlassian-operations_user" "example" {
email_address = "email@example.com"
}
Team Data Source
To fetch a team, both the team id
and the organization id
are required.
To find the Organization ID view what is Organization ID an where to find it.
# Get Atlassian Operations Teams by organization ID and team ID
data "atlassian-operations_team" "example" {
organization_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Schedule Data Source
To fetch a schedule, you need to specify its name
.
# Get Atlassian Operations Schedule by name
data "atlassian-operations_schedule" "example" {
name = "Test schedule"
}
Using Resources
Team Resource
Required resources:
description
(String) The description of the teamdisplay_name
(String) The display name of the teammember
(Attributes Set) The members of the teamaccount_id
(String) The account ID of the user
organization_id
(String) The organization ID of the teamteam_type
(String) The type of the team
Optional resources:
site_id
(String) The site ID of the team
Read-only resources:
id (String)
The ID of the teamuser_permissions
(Attributes) The user permissions of the teamadd_members
(Boolean) The permission to add members to the teamdelete_team
(Boolean) The permission to delete the teamremove_members
(Boolean) The permission to remove members from the teamupdate_team
(Boolean) The permission to update the team
To find the Organization ID view what is Organization ID an where to find it.
Example Configuration
resource "atlassian-operations_team" "example" {
organization_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
description = "This is a team created by Terraform"
display_name = "Terraform Team"
team_type = "MEMBER_INVITE"
member = [
{
account_id = "XXXXXX:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
]
}
Schedule Resource
Required resources:
name
(String) The name of the scheduleteam_id
(String) The ID of the team that owns the schedule
Optional resources:
description
(String) The description of the scheduleenabled
(Boolean) Whether the schedule is enabledtimezone
(String) The timezone of the schedule
Read-only resources:
id
(String) The ID of the schedule
Example Configuration
resource "atlassian-operations_schedule" "example" {
name = "scheduleName"
team_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
description = "schedule description"
timezone = "Europe/Istanbul"
enabled = true
}
Schedule Rotation Resource
Required resources:
schedule_id
(String) The ID of the schedulestart_date
(String) The start date of the rotationtype
(String) The type of the rotation
Optional resources:
end_date
(String) The end date of the rotationlength
(Number) The length of the rotationname
(String) The name of the rotationparticipants
(Attributes List) The participants of the rotationtype
(String) The type of the participantid
(String) (Optional, if type = “noone
”) The ID of the participant
time_restriction
(Attributes)type
(String) The type of the time restrictionrestriction
(Required if type = “time-of-day
”) (Attributes)end_hour
(Number) The end hour of the restrictionend_min
(Number) The end minute of the restrictionstart_hour
(Number) The start hour of the restrictionstart_min
(Number) The start minute of the restriction
restrictions
(Required if type = “weekday-and-time-of-day
”) (Attributes List)end_day
(String) The end day of the restrictionend_hour
(Number) The end hour of the restrictionend_min
(Number) The end minute of the restrictionstart_day
(String) The start day of the restrictionstart_hour
(Number) The start hour of the restrictionstart_min
(Number) The start minute of the restriction
Read-only resources:
id
(String) The ID of the rotation
Example Configuration
resource "atlassian-operations_schedule_rotation" "example" {
schedule_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
name = "rotationName"
start_date = "2023-11-10T05:00:00Z"
end_date = "2023-11-11T05:00:00Z"
type = "weekly"
length = 2
participants = [
{
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
type = "user"
}
]
time_restriction = {
type = "time-of-day"
restriction = {
start_hour = 9
end_hour = 17
start_min = 0
end_min = 0
}
}
}
Escalation Resource
Required resources:
name
(String) The name of the escalationrules
(Attributes Set) List of the escalation rules.condition
(String) The condition for notifying the recipient of escalation rule that is based on the alert state.delay
(Number) Time delay of the escalation rule in minutes.notify_type
(String) Recipient calculation logic for escalations.recipient
(Attributes) Object of schedule, team, or users which will be notified in escalation.type
(String) The type of the recipientid
(String) The ID of the recipient
team_id
(String) The ID of the team that owns the escalation
Optional resources:
description
(String) The description of the escalationenabled
(Boolean) Whether the escalation is enabledrepeat
(Attributes) Repeat preferences of the escalation including repeat interval, count, reverting acknowledge and seen states back and closing an alert automatically as soon as repeats are completed.close_alert_after_all
(Boolean) It is to close the alert automatically if escalation repeats are completed.count
(Number) Repeat time indicating how many times the repeat action will be performed.reset_recipient_states
(Boolean) It is for reverting acknowledge and seen states back on each repeat turn if an alert is not closed.wait_interval
(Number) The duration in minutes to repeat the escalation rules after processing the last escalation rule. It is mandatory if you would like to add or remove repeat option. 0 should be given as a value to disable repeat option.
Read-only resources:
id
(String) The ID of the escalation
Example Configuration
resource "atlassian-operations_escalation" "example" {
name = "escalationName"
team_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
description = "escalation description"
rules = [{
condition = "if-not-acked"
notify_type = "default"
delay = 5
recipient = {
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
type = "user"
}
},
{
condition = "if-not-closed"
notify_type = "all"
delay = 1
recipient = {
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
type = "team"
}
}]
enabled = true
repeat = {
wait_interval = 5
count = 10
reset_recipient_states = true
close_alert_after_all = true
}
}
API Integration Resource
Required resources:
name
(String)type
(String)
Optional resources:
enabled
(Boolean)team_id
(String)type_specific_properties
(JSON String) Integration specific properties may be provided to this object. Usejsonencode
to convert the object into a string.
Read-only resources:
advanced
(Boolean)directions
(List of String)domains
(List of String)id
(String) The ID of the escalationmaintenance_sources
(Attributes List)enabled
(Boolean) Whether the maintenance is enabledinterval
(Attributes)end_time_millis
(Number) The end time of the maintenancestart_time_millis
(Number) The start time of the maintenance
maintenance_id
(String) The ID of the maintenance
Example Configuration
resource "atlassian-operations_api_integration" "example" {
name = "apiIntegrationName"
team_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
type = "API"
enabled = true
type_specific_properties = jsonencode({
suppressNotifications: false
})
}
Email Integration Resource
Required resources:
name
(String)type_specific_properties
(Attributes) Integration specific properties may be provided to this object.email_username
(String)suppress_notifications
(Optional, defaults tofalse
) (Boolean)
Optional resources:
enabled
(Boolean)team_id
(String)
Read-only resources:
advanced
(Boolean)directions
(List of String) Direction of the action. It can be incoming or outgoingdomains
(List of String) Domain of the action. It can be alertid
(String) The ID of the escalationmaintenance_sources
(Attributes List)enabled
(Boolean)interval
(Attributes)end_time_millis
(Number)start_time_millis
(Number)
maintenance_id
(String)
Example Configuration
resource "atlassian-operations_email_integration" "example" {
name = "emailIntegrationUpdateName"
team_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
enabled = true
type_specific_properties = {
email_username = "randomEmailUsername"
suppress_notifications = false
}
}
Was this helpful?