Skip to content

Commit

Permalink
azurerm_logic_app_trigger_recurrence - support for start_time (#5244)
Browse files Browse the repository at this point in the history
Partially Addresses: #4316
  • Loading branch information
aqche authored and katbyte committed Dec 26, 2019
1 parent f837949 commit 4097b3e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
)

func resourceArmLogicAppTriggerRecurrence() *schema.Resource {
Expand Down Expand Up @@ -59,6 +60,12 @@ func resourceArmLogicAppTriggerRecurrence() *schema.Resource {
Type: schema.TypeInt,
Required: true,
},

"start_time": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.RFC3339Time,
},
},
}
}
Expand All @@ -72,6 +79,10 @@ func resourceArmLogicAppTriggerRecurrenceCreateUpdate(d *schema.ResourceData, me
"type": "Recurrence",
}

if v, ok := d.GetOk("start_time"); ok {
trigger["recurrence"].(map[string]interface{})["startTime"] = v.(string)
}

logicAppId := d.Get("logic_app_id").(string)
name := d.Get("name").(string)
if err := resourceLogicAppTriggerUpdate(d, meta, logicAppId, name, trigger, "azurerm_logic_app_trigger_recurrence"); err != nil {
Expand Down Expand Up @@ -125,6 +136,10 @@ func resourceArmLogicAppTriggerRecurrenceRead(d *schema.ResourceData, meta inter
d.Set("interval", int(interval.(float64)))
}

if startTime := recurrence["startTime"]; startTime != nil {
d.Set("start_time", startTime.(string))
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ func TestAccAzureRMLogicAppTriggerRecurrence_update(t *testing.T) {
})
}

func TestAccAzureRMLogicAppTriggerRecurrence_startTime(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_trigger_recurrence", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMLogicAppWorkflowDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLogicAppTriggerRecurrence_startTime(data, "2020-01-01T01:02:03Z"),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLogicAppTriggerExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "start_time", "2020-01-01T01:02:03Z"),
),
},
data.ImportStep(),
},
})
}

func testAccAzureRMLogicAppTriggerRecurrence_basic(data acceptance.TestData, frequency string, interval int) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand All @@ -214,6 +234,29 @@ resource "azurerm_logic_app_trigger_recurrence" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, frequency, interval)
}

func testAccAzureRMLogicAppTriggerRecurrence_startTime(data acceptance.TestData, startTime string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_logic_app_workflow" "test" {
name = "acctestlaw-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_logic_app_trigger_recurrence" "test" {
name = "frequency-trigger"
logic_app_id = "${azurerm_logic_app_workflow.test.id}"
frequency = "Month"
interval = 1
start_time = "%s"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, startTime)
}

func testAccAzureRMLogicAppTriggerRecurrence_requiresImport(data acceptance.TestData, frequency string, interval int) string {
template := testAccAzureRMLogicAppTriggerRecurrence_basic(data, frequency, interval)
return fmt.Sprintf(`
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/logic_app_trigger_recurrence.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ The following arguments are supported:

* `interval` - (Required) Specifies interval used for the Frequency, for example a value of `4` for `interval` and `hour` for `frequency` would run the Trigger every 4 hours.

* `start_time` - (Optional) Specifies the start date and time for this trigger in RFC3339 format: `2000-01-02T03:04:05Z`.

## Attributes Reference

The following attributes are exported:
Expand Down

0 comments on commit 4097b3e

Please sign in to comment.