Coder Social home page Coder Social logo

rootlyhq / terraform-provider-rootly Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 3.0 4.35 MB

Terraform provider for Rootly.

Home Page: https://registry.terraform.io/providers/rootlyhq/rootly

License: Mozilla Public License 2.0

Makefile 0.13% Go 95.91% JavaScript 3.96%

terraform-provider-rootly's Introduction

Rootly Provider

The Rootly provider is used to interact with the resources supported by Rootly. The provider needs to be configured with the proper credentials before it can be used. It requires terraform 0.14 or later.

Schema

Optional

  • api_host (String) The Rootly API host. Defaults to https://api.rootly.com. Can also be sourced from the ROOTLY_API_URL environment variable.
  • api_token (String, Sensitive) The Rootly API Token. Generate it from your account at https://rootly.com/account. It must be provided but can also be sourced from the ROOTLY_API_TOKEN environment variable.

Example Usage

Provider

terraform {
  required_providers {
    rootly = {
      source = "rootlyhq/rootly"
    }
  }
}

provider "rootly" {
  # We recommend using the `ROOTLY_API_TOKEN` env var to set the API Token
  # when interacting with Rootly's API.
  # api_token = var.rootly_api_key
}

Data sources

# uses output of severity data source as input for workflow
data "rootly_severity" "critical" {
  slug = "sev0"
}

resource "rootly_workflow_incident" "ping_oncall" {
  name        = "Ping on-call when critical incident"
  description = "ping on-call when critical incident happens"
  trigger_params {
    triggers                  = ["incident_created"]
    incident_condition_kind   = "IS"
    incident_kinds            = ["normal"]
    incident_condition_status = "IS"
    incident_statuses         = ["started"]
    severity_ids              = [data.rootly_severity.critical.id]
  }
  enabled = true
}

resource "rootly_workflow_task_send_sms" "sms_oncall" {
  workflow_id = rootly_workflow_incident.ping_oncall.id
  name        = "On-call team"

  task_params {
    phone_numbers = ["+11231231234"]
    content       = "Critical incident started"
  }
}

Custom form fields

# Custom form Fields
resource "rootly_form_field" "regions_affected" {
  name       = "Regions affected"
  kind       = "custom"
  input_kind = "multi_select"
  shown      = ["web_new_incident_form", "web_update_incident_form"]
  required   = ["web_new_incident_form", "web_update_incident_form"]
}

resource "rootly_form_field_option" "asia" {
  form_field_id = rootly_form_field.regions_affected.id
  value         = "Asia"
}

resource "rootly_form_field_option" "europe" {
  form_field_id = rootly_form_field.regions_affected.id
  value         = "Europe"
}

resource "rootly_form_field_option" "north_america" {
  form_field_id = rootly_form_field.regions_affected.id
  value         = "North America"
}

Workflows

# Jira workflow
resource "rootly_workflow_incident" "jira" {
  name        = "Create a Jira Issue"
  description = "Open Jira ticket whenever incident starts"
  trigger_params {
    triggers                  = ["incident_created"]
    incident_condition_kind   = "IS"
    incident_kinds            = ["normal"]
    incident_condition_status = "IS"
    incident_statuses         = ["started"]
  }
  enabled = true
}

resource "rootly_workflow_task_create_jira_issue" "jira" {
  workflow_id = rootly_workflow_incident.jira.id
  task_params {
    title       = "{{ incident.title }}"
    description = "{{ incident.summary }}"
    project_key = "ROOT"
    issue_type = {
      id   = "10001"
      name = "Task"
    }
    status = {
      id   = "10000"
      name = "To Do"
    }
    labels = "{{ incident.environment_slugs | concat: incident.service_slugs | concat: incident.functionality_slugs | concat: incident.group_slugs | join: \",\" }}"
  }
}

Dashboards

resource "rootly_dashboard" "overview" {
  name = "my_dashboard"
}

resource "rootly_dashboard_panel" "incidents_by_severity" {
  dashboard_id = rootly_dashboard.foo.id
  name         = "test"
  params {
    display = "line_chart"
    datasets {
      collection = "incidents"
      filter {
        operation = "and"
        rules {
          operation = "and"
          condition = "="
          key       = "status"
          value     = "started"
        }
      }
      group_by = "severity"
      aggregate {
        cumulative = false
        key        = "results"
        operation  = "count"
      }
    }
  }
}

Development

make build auto-generates code from Swagger, compiles provider, and regenerates docs.

Exclude API resources from the provider by adding them to the excluded list in tools/generate.js.

terraform-provider-rootly's People

Contributors

alexmingoia avatar kwent avatar ninir avatar dependabot[bot] avatar johanfleury avatar weihanli101 avatar yjperez avatar

Stargazers

Luis Z avatar Balint avatar Glenn avatar Adam Ouellette avatar  avatar Dimitrije Manic avatar Ashley Jackson avatar  avatar Mathieu Mailhos avatar

Watchers

Ed Carrel avatar  avatar Josh Frankel avatar  avatar Angelo Tomasco avatar Glenn avatar

terraform-provider-rootly's Issues

`OpsGenie Team / External ID` not supported in the provider.

Feature request

Setting OpsGenie Team / External ID not supported in the provider.

In the rootly UI it is possible to set/edit a field called OpsGenie Team / External ID. This field currently cannot be provisioned with the rootly terraform provider and doesn't seem to exist in the source.

It is also not possible to read this field with a manual, former import through the UI, because the data source does not expose it either.

The OpsGenie terraform provider does export the team id and we're using terraform to provision both OpsGenie and rootly so this value is available to us - would it be possible to add support for the OpsGenie Team / External ID field to the rootly terraform provider so we can provision the mapping?

Terraform Version

Terraform v1.5.6
on linux_amd64

Affected Resource(s)

  • rootly_team

`provider.tf` is incorrectly generated causing failure to initialize terraform.

Terraform Version

1.5.7

Expected Behavior

terraformer rootly generates proper provider.tf files. For example:

terraform {
  required_version = ">= 0.13.1"
  
  required_providers {
    rootly = {
      source = "rootlyhq/rootly"
      version = "1.2.17"
    }
  }
}

provider "rootly" {
  # Configuration options
}

Actual Behavior

You will encounter this error when you initialize the any workspace generated by terraformer

terraform init

Initializing the backend...
╷
│ Error: Invalid legacy provider address
│
│ This configuration or its associated state refers to the unqualified provider "rootly".
│
│ You must complete the Terraform 0.13 upgrade process before upgrading to later versions.
╵

This is the file that is generated:

terraform {
	required_providers {
		rootly = {
	    version = "~> 1.2.17"
		}
  }
}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:
Run Rootly terraformer and look at the resulting providers.tf generated.

Important Factoids

The work around is to first generate the terraform with terraformer, then manually update the providers.tf and then update the state with:

terraform state replace-provider -auto-approve "registry.terraform.io/-/rootly" "rootlyhq/rootly"                                                                                                                                                           SRE-3207
Terraform will perform the following actions:

  ~ Updating provider:
    - registry.terraform.io/-/rootly
    + registry.terraform.io/rootlyhq/rootly

Changing 432 resources:
...

rootly_team.id returned is not valid as input into rootly_workflow_incident group_ids

Possibly an issue of expectation, but I was hoping to see the data.rootly_teams.grp_security.id value as the guid-style id as per the API - what is returned is a (provider assigned?) integer style id that won't be accepted as valid rootly_workflow_incident group_ids content.

The https://api.rootly.com/v1/teams API call returns:
{
"id": "4566dd9a-e368-4288-8be7-b32eab46270f",
"type": "groups",
"attributes": {
"slug": "security",
....
}
}

But the TF id is "1661805916"

Terraform Version

Terraform v 1.2.8 on windows_amd64

Affected Resource(s)

rootly_workflow_incident

Terraform Configuration Files

data "rootly_teams" "grp_security" {
slug = "security"
}

resource "rootly_workflow_incident" "tftest" {
name = "TF Test"
description = "testing the tf creation of incident workflows"
command = "create-jira-incident-workflow"
group_ids = [ "4566dd9a-e368-4288-8be7-b32eab46270f",
"908af556-aab3-4372-94f4-91aee86c2081",
data.rootly_teams.grp_security.id ]
trigger_params {
incident_condition_kind = "ANY"
}
}

Debug Output

https://gist.github.com/pierzapin/d18c74158bf3ed6cebdb7eff033f7149

Expected Behavior

The security team is added to the set of workflow team conditions

Actual Behavior

The resource id for the team data element is rejected as invalid

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply and confirm with 'yes'

Error: Insufficient task_params blocks when generating workflows

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Affected Resource(s)

Please list the resources as a list, for example:

  • rootly_workflow_task_create_google_meeting
  • rootly_workflow_task_create_zoom_meeting
  • rootly_workflow_task_page_pagerduty_on_call_responders
  • rootly_workflow_task_update_pagerduty_incident

there are probably more resource that are impacted but we just are not using in rootly.

Expected Behavior

Terraform generates valid resources declarations when specifying the workflow resource.

Actual Behavior

running terraform plan results in the follow errors:

╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_google_meeting.tf line 1, in resource "rootly_workflow_task_create_google_meeting" "tfer--xxx":
│    1: resource "rootly_workflow_task_create_google_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 1, in resource "rootly_workflow_task_create_zoom_meeting" "xxx":
│    1: resource "rootly_workflow_task_create_zoom_meeting" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 9, in resource "rootly_workflow_task_create_zoom_meeting" "xxx":
│    9: resource "rootly_workflow_task_create_zoom_meeting" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 17, in resource "rootly_workflow_task_create_zoom_meeting" "xxx":
│   17: resource "rootly_workflow_task_create_zoom_meeting" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 25, in resource "rootly_workflow_task_create_zoom_meeting" "xxx":
│   25: resource "rootly_workflow_task_create_zoom_meeting" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 33, in resource "rootly_workflow_task_create_zoom_meeting" "xxx":
│   33: resource "rootly_workflow_task_create_zoom_meeting" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 41, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   41: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 49, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   49: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 57, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   57: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 65, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   65: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 73, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   73: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_create_zoom_meeting.tf line 81, in resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx":
│   81: resource "rootly_workflow_task_create_zoom_meeting" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 1, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx":
│    1: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 9, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx":
│    9: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 17, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx":
│   17: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 25, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   25: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 33, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   33: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 41, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   41: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 49, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   49: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 57, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   57: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 65, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   65: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 73, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   73: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 81, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   81: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_page_pagerduty_on_call_responders.tf line 89, in resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx":
│   89: resource "rootly_workflow_task_page_pagerduty_on_call_responders" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.
╵
╷
│ Error: Insufficient task_params blocks
│
│   on workflow_task_update_pagerduty_incident.tf line 1, in resource "rootly_workflow_task_update_pagerduty_incident" "tfer--xxx":
│    1: resource "rootly_workflow_task_update_pagerduty_incident" "tfer--xxx" {
│
│ At least 1 "task_params" blocks are required.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraformer-rootly import rootly --resources="workflow" --token $ROOTLY_API_TOKEN
  2. terraform init
  3. terraform plan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.