diff --git a/go.mod b/go.mod index 3d880fd9e..8c2919090 100644 --- a/go.mod +++ b/go.mod @@ -16,3 +16,5 @@ require ( google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb // indirect google.golang.org/grpc v1.33.2 // indirect ) + +replace github.com/heimweh/go-pagerduty => github.com/mrdubr/go-pagerduty v0.0.0-20221207010513-91b73ec9ea69 diff --git a/go.sum b/go.sum index 97f9525e5..3f721a6c8 100644 --- a/go.sum +++ b/go.sum @@ -294,6 +294,8 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ= github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/mrdubr/go-pagerduty v0.0.0-20221207010513-91b73ec9ea69 h1:xNq1ArQXzUwNoWuUw3I4hIxCe52eXJOZ3o1XrubwT4s= +github.com/mrdubr/go-pagerduty v0.0.0-20221207010513-91b73ec9ea69/go.mod h1:t9vftsO1IjYHGdgJXeemZtomCWnxi2SRgu0PRcRb2oY= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= diff --git a/pagerduty/data_source_pagerduty_automation_actions_runner.go b/pagerduty/data_source_pagerduty_automation_actions_runner.go index 02bb6dd4c..687f359b5 100644 --- a/pagerduty/data_source_pagerduty_automation_actions_runner.go +++ b/pagerduty/data_source_pagerduty_automation_actions_runner.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -func dataSourcePagerdutyAutomationActionsRunner() *schema.Resource { +func dataSourcePagerDutyAutomationActionsRunner() *schema.Resource { return &schema.Resource{ Read: dataSourcePagerDutyAutomationActionsRunnerRead, @@ -25,6 +25,29 @@ func dataSourcePagerdutyAutomationActionsRunner() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "runner_type": { + Type: schema.TypeString, + Computed: true, + }, + "creation_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_seen": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + "runbook_base_uri": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, }, } } @@ -49,6 +72,20 @@ func dataSourcePagerDutyAutomationActionsRunnerRead(d *schema.ResourceData, meta d.SetId(runner.ID) d.Set("name", runner.Name) d.Set("type", runner.Type) + d.Set("runner_type", runner.RunnerType) + d.Set("creation_time", runner.CreationTime) + + if runner.Description != nil { + d.Set("description", &runner.Description) + } + + if runner.RunbookBaseUri != nil { + d.Set("runbook_base_uri", &runner.RunbookBaseUri) + } + + if runner.LastSeenTime != nil { + d.Set("last_seen", &runner.LastSeenTime) + } return nil }) diff --git a/pagerduty/data_source_pagerduty_automation_actions_runner_test.go b/pagerduty/data_source_pagerduty_automation_actions_runner_test.go index 9b7ba9fb9..c6e208fa5 100644 --- a/pagerduty/data_source_pagerduty_automation_actions_runner_test.go +++ b/pagerduty/data_source_pagerduty_automation_actions_runner_test.go @@ -4,45 +4,68 @@ import ( "fmt" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccDataSourcePagerDutyAutomationActionsRunner_Basic(t *testing.T) { + name := fmt.Sprintf("tf-%s", acctest.RandString(5)) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourcePagerDutyAutomationActionsRunnerConfig("01DCTHG8L7X4BDEQG3OQO2HZCN"), + Config: testAccDataSourcePagerDutyAutomationActionsRunnerConfig(name), Check: resource.ComposeTestCheckFunc( - testAccCheckPagerdutyAutomationActionsRunnerExists("data.pagerduty_automation_actions_runner.foo"), + testAccDataSourcePagerdutyAutomationActionsRunner("pagerduty_automation_actions_runner.test", "data.pagerduty_automation_actions_runner.foo"), ), }, }, }) } -func testAccCheckPagerdutyAutomationActionsRunnerExists(n string) resource.TestCheckFunc { +func testAccDataSourcePagerdutyAutomationActionsRunner(src, n string) resource.TestCheckFunc { return func(s *terraform.State) error { - // client, _ := testAccProvider.Meta().(*Config).Client() - rs, ok := s.RootModule().Resources[n] + srcR := s.RootModule().Resources[src] + srcA := srcR.Primary.Attributes + + ds, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { + dsA := ds.Primary.Attributes + + if dsA["id"] == "" { return fmt.Errorf("No Runner ID is set") } + testAtts := []string{"id", "name", "type", "runner_type", "creation_time", "last_seen", "description", "runbook_base_uri"} + + for _, att := range testAtts { + if dsA[att] != srcA[att] { + return fmt.Errorf("Expected the runner %s to be: %s, but got: %s", att, srcA[att], dsA[att]) + } + } + return nil } } -func testAccDataSourcePagerDutyAutomationActionsRunnerConfig(id string) string { +func testAccDataSourcePagerDutyAutomationActionsRunnerConfig(name string) string { return fmt.Sprintf(` +resource "pagerduty_automation_actions_runner" "test" { + name = "%s" + description = "Runner created by TF" + runner_type = "runbook" + runbook_base_uri = "cat-cat" + runbook_api_key = "secret" +} + data "pagerduty_automation_actions_runner" "foo" { - id = "%s" + id = pagerduty_automation_actions_runner.test.id } -`, id) +`, name) } diff --git a/pagerduty/import_pagerduty_automation_actions_runner_test.go b/pagerduty/import_pagerduty_automation_actions_runner_test.go new file mode 100644 index 000000000..54a3744ed --- /dev/null +++ b/pagerduty/import_pagerduty_automation_actions_runner_test.go @@ -0,0 +1,30 @@ +package pagerduty + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccPagerDutyAutomationActionsRunner_import(t *testing.T) { + runnerName := fmt.Sprintf("tf-%s", acctest.RandString(5)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckPagerDutyAutomationActionsRunnerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckPagerDutyAutomationActionsRunnerConfig(runnerName), + }, + { + ResourceName: "pagerduty_automation_actions_runner.foo", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"runbook_api_key"}, + }, + }, + }) +} diff --git a/pagerduty/provider.go b/pagerduty/provider.go index a5b6419d5..5eddcbc3a 100644 --- a/pagerduty/provider.go +++ b/pagerduty/provider.go @@ -61,7 +61,7 @@ func Provider() *schema.Provider { "pagerduty_ruleset": dataSourcePagerDutyRuleset(), "pagerduty_tag": dataSourcePagerDutyTag(), "pagerduty_event_orchestration": dataSourcePagerDutyEventOrchestration(), - "pagerduty_automation_actions_runner": dataSourcePagerdutyAutomationActionsRunner(), + "pagerduty_automation_actions_runner": dataSourcePagerDutyAutomationActionsRunner(), }, ResourcesMap: map[string]*schema.Resource{ @@ -94,6 +94,7 @@ func Provider() *schema.Provider { "pagerduty_event_orchestration_router": resourcePagerDutyEventOrchestrationPathRouter(), "pagerduty_event_orchestration_unrouted": resourcePagerDutyEventOrchestrationPathUnrouted(), "pagerduty_event_orchestration_service": resourcePagerDutyEventOrchestrationPathService(), + "pagerduty_automation_actions_runner": resourcePagerDutyAutomationActionsRunner(), }, } diff --git a/pagerduty/resource_pagerduty_automation_actions_runner.go b/pagerduty/resource_pagerduty_automation_actions_runner.go new file mode 100644 index 000000000..adaf0a87d --- /dev/null +++ b/pagerduty/resource_pagerduty_automation_actions_runner.go @@ -0,0 +1,196 @@ +package pagerduty + +import ( + "errors" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/heimweh/go-pagerduty/pagerduty" +) + +func resourcePagerDutyAutomationActionsRunner() *schema.Resource { + return &schema.Resource{ + Create: resourcePagerDutyAutomationActionsRunnerCreate, + Read: resourcePagerDutyAutomationActionsRunnerRead, + Delete: resourcePagerDutyAutomationActionsRunnerDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, // Requires creation of new resource while support for update is not implemented + }, + "runner_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validateValueFunc([]string{ + "sidecar", + "runbook", + }), + ForceNew: true, // Requires creation of new resource while support for update is not implemented + }, + "description": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, // Requires creation of new resource while support for update is not implemented + }, + "runbook_base_uri": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, // Requires creation of new resource while support for update is not implemented + }, + "runbook_api_key": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, // Requires creation of new resource while support for update is not implemented + Sensitive: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + "creation_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_seen": { + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + }, + } +} + +func buildAutomationActionsRunnerStruct(d *schema.ResourceData) (*pagerduty.AutomationActionsRunner, error) { + + automationActionsRunner := pagerduty.AutomationActionsRunner{ + Name: d.Get("name").(string), + RunnerType: d.Get("runner_type").(string), + } + + if automationActionsRunner.RunnerType != "runbook" { + return nil, errors.New("only runners of runner_type runbook can be created") + } + + // The API does not allow new runners without a description, but legacy runners without a description exist + if attr, ok := d.GetOk("description"); ok { + val := attr.(string) + automationActionsRunner.Description = &val + } else { + return nil, errors.New("runner description must be specified when creating a runbook runner") + } + + if attr, ok := d.GetOk("runbook_base_uri"); ok { + val := attr.(string) + automationActionsRunner.RunbookBaseUri = &val + } else { + return nil, errors.New("runbook_base_uri must be specified when creating a runbook runner") + } + + if attr, ok := d.GetOk("runbook_api_key"); ok { + val := attr.(string) + automationActionsRunner.RunbookApiKey = &val + } else { + return nil, errors.New("runbook_api_key must be specified when creating a runbook runner") + } + + return &automationActionsRunner, nil +} + +func resourcePagerDutyAutomationActionsRunnerCreate(d *schema.ResourceData, meta interface{}) error { + client, err := meta.(*Config).Client() + if err != nil { + return err + } + + automationActionsRunner, err := buildAutomationActionsRunnerStruct(d) + if err != nil { + return err + } + + log.Printf("[INFO] Creating PagerDuty AutomationActionsRunner %s", automationActionsRunner.Name) + + retryErr := resource.Retry(10*time.Second, func() *resource.RetryError { + if automationActionsRunner, _, err := client.AutomationActionsRunner.Create(automationActionsRunner); err != nil { + if isErrCode(err, 400) || isErrCode(err, 429) { + time.Sleep(2 * time.Second) + return resource.RetryableError(err) + } + + return resource.NonRetryableError(err) + } else if automationActionsRunner != nil { + d.SetId(automationActionsRunner.ID) + } + return nil + }) + + if retryErr != nil { + return retryErr + } + + return resourcePagerDutyAutomationActionsRunnerRead(d, meta) +} + +func resourcePagerDutyAutomationActionsRunnerRead(d *schema.ResourceData, meta interface{}) error { + client, err := meta.(*Config).Client() + if err != nil { + return err + } + + log.Printf("[INFO] Reading PagerDuty AutomationActionsRunner %s", d.Id()) + + return resource.Retry(30*time.Second, func() *resource.RetryError { + if automationActionsRunner, _, err := client.AutomationActionsRunner.Get(d.Id()); err != nil { + time.Sleep(2 * time.Second) + return resource.RetryableError(err) + } else if automationActionsRunner != nil { + d.Set("name", automationActionsRunner.Name) + d.Set("type", automationActionsRunner.Type) + d.Set("runner_type", automationActionsRunner.RunnerType) + d.Set("creation_time", automationActionsRunner.CreationTime) + + if automationActionsRunner.Description != nil { + d.Set("description", &automationActionsRunner.Description) + } + + if automationActionsRunner.RunbookBaseUri != nil { + d.Set("runbook_base_uri", &automationActionsRunner.RunbookBaseUri) + } + + if automationActionsRunner.LastSeenTime != nil { + d.Set("last_seen", &automationActionsRunner.LastSeenTime) + } + } + return nil + }) +} + +func resourcePagerDutyAutomationActionsRunnerDelete(d *schema.ResourceData, meta interface{}) error { + client, err := meta.(*Config).Client() + if err != nil { + return err + } + + log.Printf("[INFO] Deleting PagerDuty AutomationActionsRunner %s", d.Id()) + + retryErr := resource.Retry(2*time.Minute, func() *resource.RetryError { + if _, err := client.AutomationActionsRunner.Delete(d.Id()); err != nil { + return resource.RetryableError(err) + } + return nil + }) + if retryErr != nil { + time.Sleep(2 * time.Second) + return retryErr + } + d.SetId("") + + // giving the API time to catchup + time.Sleep(time.Second) + return nil +} diff --git a/pagerduty/resource_pagerduty_automation_actions_runner_test.go b/pagerduty/resource_pagerduty_automation_actions_runner_test.go new file mode 100644 index 000000000..b7cd3e020 --- /dev/null +++ b/pagerduty/resource_pagerduty_automation_actions_runner_test.go @@ -0,0 +1,94 @@ +package pagerduty + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func init() { + resource.AddTestSweepers("automation_actions_runner", &resource.Sweeper{ + Name: "automation_actions_runner", + F: testSweepAutomationActionsRunner, + }) +} + +func testSweepAutomationActionsRunner(region string) error { + return nil +} + +func TestAccPagerDutyAutomationActionsRunner_Basic(t *testing.T) { + runnerName := fmt.Sprintf("tf-%s", acctest.RandString(5)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckPagerDutyAutomationActionsRunnerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckPagerDutyAutomationActionsRunnerConfig(runnerName), + Check: resource.ComposeTestCheckFunc( + testAccCheckPagerDutyAutomationActionsRunnerExists("pagerduty_automation_actions_runner.foo"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_runner.foo", "name", runnerName), + resource.TestCheckResourceAttr("pagerduty_automation_actions_runner.foo", "runner_type", "runbook"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_runner.foo", "description", "Runner created by TF"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_runner.foo", "runbook_base_uri", "cat-cat"), + resource.TestCheckResourceAttr("pagerduty_automation_actions_runner.foo", "type", "runner"), + resource.TestCheckResourceAttrSet("pagerduty_automation_actions_runner.foo", "id"), + resource.TestCheckResourceAttrSet("pagerduty_automation_actions_runner.foo", "creation_time"), + ), + }, + }, + }) +} + +func testAccCheckPagerDutyAutomationActionsRunnerDestroy(s *terraform.State) error { + client, _ := testAccProvider.Meta().(*Config).Client() + for _, r := range s.RootModule().Resources { + if r.Type != "pagerduty_automation_actions_runner" { + continue + } + if _, _, err := client.AutomationActionsRunner.Get(r.Primary.ID); err == nil { + return fmt.Errorf("Automation Actions Runner still exists") + } + } + return nil +} + +func testAccCheckPagerDutyAutomationActionsRunnerExists(n string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + if rs.Primary.ID == "" { + return fmt.Errorf("No Automation Actions Runner ID is set") + } + + client, _ := testAccProvider.Meta().(*Config).Client() + found, _, err := client.AutomationActionsRunner.Get(rs.Primary.ID) + if err != nil { + return err + } + if found.ID != rs.Primary.ID { + return fmt.Errorf("Automation Actions Runner not found: %v - %v", rs.Primary.ID, found) + } + + return nil + } +} + +func testAccCheckPagerDutyAutomationActionsRunnerConfig(runnerName string) string { + return fmt.Sprintf(` +resource "pagerduty_automation_actions_runner" "foo" { + name = "%s" + description = "Runner created by TF" + runner_type = "runbook" + runbook_base_uri = "cat-cat" + runbook_api_key = "cat-secret" +} +`, runnerName) +} diff --git a/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_runner.go b/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_runner.go new file mode 100644 index 000000000..2e4ac4aef --- /dev/null +++ b/vendor/github.com/heimweh/go-pagerduty/pagerduty/automation_actions_runner.go @@ -0,0 +1,78 @@ +package pagerduty + +import "fmt" + +// AutomationActionsRunner handles the communication with schedule +// related methods of the PagerDuty API. +type AutomationActionsRunnerService service + +type AutomationActionsRunner struct { + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + RunnerType string `json:"runner_type"` + CreationTime string `json:"creation_time"` + LastSeenTime *string `json:"last_seen,omitempty"` + Summary string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + RunbookBaseUri *string `json:"runbook_base_uri,omitempty"` + RunbookApiKey *string `json:"runbook_api_key,omitempty"` + Teams []*TeamReference `json:"teams,omitempty"` + Privileges *AutomationActionsPrivileges `json:"privileges,omitempty"` +} + +type AutomationActionsPrivileges struct { + Permissions []*string `json:"permissions,omitempty"` +} + +type AutomationActionsRunnerPayload struct { + Runner *AutomationActionsRunner `json:"runner,omitempty"` +} + +// Create creates a new runner +func (s *AutomationActionsRunnerService) Create(runner *AutomationActionsRunner) (*AutomationActionsRunner, *Response, error) { + u := "/automation_actions/runners" + v := new(AutomationActionsRunnerPayload) + o := RequestOptions{ + Type: "header", + Label: "X-EARLY-ACCESS", + Value: "automation-actions-early-access", + } + + resp, err := s.client.newRequestDoOptions("POST", u, nil, &AutomationActionsRunnerPayload{Runner: runner}, &v, o) + if err != nil { + return nil, nil, err + } + + return v.Runner, resp, nil +} + +// Get retrieves information about a runner. +func (s *AutomationActionsRunnerService) Get(id string) (*AutomationActionsRunner, *Response, error) { + u := fmt.Sprintf("/automation_actions/runners/%s", id) + v := new(AutomationActionsRunnerPayload) + o := RequestOptions{ + Type: "header", + Label: "X-EARLY-ACCESS", + Value: "automation-actions-early-access", + } + + resp, err := s.client.newRequestDoOptions("GET", u, nil, nil, &v, o) + if err != nil { + return nil, nil, err + } + + return v.Runner, resp, nil +} + +// Delete deletes an existing runner. +func (s *AutomationActionsRunnerService) Delete(id string) (*Response, error) { + u := fmt.Sprintf("/automation_actions/runners/%s", id) + o := RequestOptions{ + Type: "header", + Label: "X-EARLY-ACCESS", + Value: "automation-actions-early-access", + } + + return s.client.newRequestDoOptions("DELETE", u, nil, nil, nil, o) +} diff --git a/vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go b/vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go index 48a89e8d0..3f547a340 100644 --- a/vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go +++ b/vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go @@ -59,6 +59,7 @@ type Client struct { WebhookSubscriptions *WebhookSubscriptionService BusinessServiceSubscribers *BusinessServiceSubscriberService OnCall *OnCallService + AutomationActionsRunner *AutomationActionsRunnerService } // Response is a wrapper around http.Response @@ -121,6 +122,7 @@ func NewClient(config *Config) (*Client, error) { c.WebhookSubscriptions = &WebhookSubscriptionService{c} c.BusinessServiceSubscribers = &BusinessServiceSubscriberService{c} c.OnCall = &OnCallService{c} + c.AutomationActionsRunner = &AutomationActionsRunnerService{c} InitCache(c) PopulateCache() diff --git a/vendor/modules.txt b/vendor/modules.txt index a21a95c07..5c628a2d5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -122,7 +122,7 @@ github.com/hashicorp/terraform-registry-address github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d github.com/hashicorp/yamux -# github.com/heimweh/go-pagerduty v0.0.0-20220907210255-0dcec1fd4239 +# github.com/heimweh/go-pagerduty v0.0.0-20220907210255-0dcec1fd4239 => github.com/mrdubr/go-pagerduty v0.0.0-20221207010513-91b73ec9ea69 ## explicit github.com/heimweh/go-pagerduty/pagerduty # github.com/klauspost/compress v1.15.9 @@ -349,3 +349,4 @@ google.golang.org/protobuf/types/known/anypb google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/emptypb google.golang.org/protobuf/types/known/timestamppb +# github.com/heimweh/go-pagerduty => github.com/mrdubr/go-pagerduty v0.0.0-20221207010513-91b73ec9ea69 diff --git a/website/docs/d/automation_actions_runner.html.markdown b/website/docs/d/automation_actions_runner.html.markdown new file mode 100644 index 000000000..5c83ee83e --- /dev/null +++ b/website/docs/d/automation_actions_runner.html.markdown @@ -0,0 +1,40 @@ +--- +layout: "pagerduty" +page_title: "PagerDuty: pagerduty_automation_actions_runner" +sidebar_current: "docs-pagerduty-datasource-automation-actions-runner" +description: |- + Get information about an Automation Actions runner that you have created. +--- + +# pagerduty\_automation\_actions\_runner + +Use this data source to get information about a specific [automation actions runner][1]. + +## Example Usage + +```hcl +data "pagerduty_automation_actions_runner" "example" { + id = "01DBJLIGED17S1DQKQC2AV8XYZ" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `id` - (Required) The id of the automation actions runner in the PagerDuty API. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the found runner. +* `name` - The name of the found runner. +* `type` - The type of object. The value returned will be `runner`. +* `runner_type` - The type of runner. Allowed values are `sidecar` and `runbook`. +* `creation_time` - The time runner was created. Represented as an ISO 8601 timestamp. +* `description` - (Optional) The description of the runner. +* `last_seen` - (Optional) The last time runner has been seen. Represented as an ISO 8601 timestamp. +* `runbook_base_uri` - (Optional) The base URI of the Runbook server to connect to. Applicable to `runbook` type runners only. + +[1]: https://developer.pagerduty.com/api-reference/aace61f84cbd0-get-an-automation-action-runner diff --git a/website/docs/d/business_service.html.markdown b/website/docs/d/business_service.html.markdown index 975a234f8..cffc8ee64 100644 --- a/website/docs/d/business_service.html.markdown +++ b/website/docs/d/business_service.html.markdown @@ -29,4 +29,4 @@ The following arguments are supported: * `name` - The short name of the found business service. * `type` - The type of object. The value returned will be `business_service`. Can be used for passing to a service dependency. -* [1]: https://api-reference.pagerduty.com/#!/Business_Services/get_business_services +[1]: https://api-reference.pagerduty.com/#!/Business_Services/get_business_services diff --git a/website/docs/r/automation_actions_runner.html.markdown b/website/docs/r/automation_actions_runner.html.markdown new file mode 100644 index 000000000..9bc6aec37 --- /dev/null +++ b/website/docs/r/automation_actions_runner.html.markdown @@ -0,0 +1,71 @@ +--- +layout: "pagerduty" +page_title: "PagerDuty: pagerduty_automation_actions_runner" +sidebar_current: "docs-pagerduty-resource-automation-actions-runner" +description: |- + Creates and manages an Automation Actions runner in PagerDuty. +--- + +# pagerduty\_automation\_actions\_runner + +An Automation Actions [runner](https://developer.pagerduty.com/api-reference/d78999fb7e863-create-an-automation-action-runner) is the method for how actions are executed. This can be done locally using an installed runner agent or as a connection to a PD Runbook Automation instance. + +-> Only Runbook Automation (runbook) runners can be created. + +## Example Usage + +```hcl +# Assumes the TF_VAR_RUNBOOK_API_KEY variable is defined in the environment + +variable "RUNBOOK_API_KEY" { + type = string + sensitive = true +} + +resource "pagerduty_automation_actions_runner" "example" { + name = "Runner created via TF" + description = "Description of the Runner created via TF" + runner_type = "runbook" + runbook_base_uri = "rdcat.stg" + runbook_api_key = var.RUNBOOK_API_KEY +} +``` + +## Argument Reference + +The following arguments are supported: + + * `name` - (Required) The name of the runner. + * `description` - (Required) The description of the runner. + * `runner_type` - (Required) The type of runner. The only allowed values is `runbook`. + * `runbook_base_uri` - (Required) The subdomain for your Runbook Automation Instance. + * `runbook_api_key` - (Required) The unique User API Token created in Runbook Automation. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the runner. +* `type` - The type of object. The value returned will be `runner`. +* `creation_time` - The time runner was created. Represented as an ISO 8601 timestamp. +* `last_seen` - (Optional) The last time runner has been seen. Represented as an ISO 8601 timestamp. + +## Import + +-> In the example below the `runbook_api_key` attribute has been omitted to avoid resource replacement after the import. + +Runners can be imported using the `id`, e.g. + +``` +resource "pagerduty_automation_actions_runner" "example" { + name = "Runner created via TF" + description = "Description of the Runner created via TF" + runner_type = "runbook" + runbook_base_uri = "rdcat.stg" +} +``` +``` +$ terraform import pagerduty_automation_actions_runner.example 01DER7CUUBF7TH4116K0M4WKPU +``` + +