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

azurerm_logic_app_trigger_recurrence - support for start_time #5244

Merged
merged 2 commits into from
Dec 26, 2019
Merged
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
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