Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AA-1047] Add ability to map automation actions to all services #965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pagerduty/data_source_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func dataSourcePagerDutyAutomationActionsAction() *schema.Resource {
Computed: true,
Optional: true,
},
"map_to_all_services": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ resource "pagerduty_automation_actions_action" "test" {
process_automation_node_filter = "tags: production"
}
only_invocable_on_unresolved_incidents = true
map_to_all_services = true
}

data "pagerduty_automation_actions_action" "foo" {
Expand Down
17 changes: 17 additions & 0 deletions pagerduty/resource_pagerduty_automation_actions_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ func resourcePagerDutyAutomationActionsAction() *schema.Resource {
Computed: true,
Optional: true,
},
"map_to_all_services": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -166,6 +171,14 @@ func buildAutomationActionsActionStruct(d *schema.ResourceData) (*pagerduty.Auto
attr, _ := d.Get("only_invocable_on_unresolved_incidents").(bool)
automationActionsAction.OnlyInvocableOnUnresolvedIncidents = &attr

if attr, ok := d.GetOk("map_to_all_services"); ok {
val := attr.(bool)
automationActionsAction.MapToAllServices = &val
}

Comment on lines +174 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block of code is not necessary

attr2, _ := d.Get("map_to_all_services").(bool)
automationActionsAction.MapToAllServices = &attr2

return &automationActionsAction, nil
}

Expand Down Expand Up @@ -315,6 +328,10 @@ func resourcePagerDutyAutomationActionsActionRead(d *schema.ResourceData, meta i
if automationActionsAction.OnlyInvocableOnUnresolvedIncidents != nil {
d.Set("only_invocable_on_unresolved_incidents", *automationActionsAction.OnlyInvocableOnUnresolvedIncidents)
}

if automationActionsAction.MapToAllServices != nil {
d.Set("map_to_all_services", *automationActionsAction.MapToAllServices)
}
}
return nil
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "true"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "map_to_all_services", "true"),
),
},
{
Expand Down Expand Up @@ -86,6 +87,7 @@ func TestAccPagerDutyAutomationActionsActionTypeProcessAutomation_Basic(t *testi
resource.TestCheckResourceAttrSet("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "runner_type", "runbook"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "map_to_all_services", "false"),
),
},
},
Expand Down Expand Up @@ -130,6 +132,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) {
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "map_to_all_services", "false"),
),
},
{
Expand All @@ -156,6 +159,7 @@ func TestAccPagerDutyAutomationActionsActionTypeScript_Basic(t *testing.T) {
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_type"),
resource.TestCheckNoResourceAttr("pagerduty_automation_actions_action.foo", "runner_id"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "only_invocable_on_unresolved_incidents", "false"),
resource.TestCheckResourceAttr("pagerduty_automation_actions_action.foo", "map_to_all_services", "false"),
),
},
},
Expand Down Expand Up @@ -220,6 +224,7 @@ resource "pagerduty_automation_actions_action" "foo" {
process_automation_node_filter = "tags: production"
}
only_invocable_on_unresolved_incidents = "true"
map_to_all_services = "true"
}
`, actionName, actionName)
}
Expand All @@ -245,6 +250,7 @@ resource "pagerduty_automation_actions_action" "foo" {
process_automation_job_id = "updated_pa_job_id_123"
}
only_invocable_on_unresolved_incidents = "false"
map_to_all_services = "false"
}
`, previousActionName, actionName, actionDescription, actionClassification)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/docs/d/automation_actions_action.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following attributes are exported:
* `action_classification` - (Optional) The category of the action. The only allowed values are `diagnostic` and `remediation`.
* `modify_time` - (Optional) The last time action has been modified. Represented as an ISO 8601 timestamp.
* `only_invocable_on_unresolved_incidents` - (Optional) Whether or not the action can be invoked on unresolved incidents.
* `map_to_all_services` - (Optional) If the action should be able to be run against all services or just specified ones.

Action Data (`action_data_reference`) supports the following:

Expand Down
Loading