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

Support for setting days of month in azurerm_logic_app_trigger_recurrence #28344

Open
1 task done
Noel-Jones opened this issue Dec 19, 2024 · 1 comment
Open
1 task done

Comments

@Noel-Jones
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.10.2

AzureRM Provider Version

4.14.0

Affected Resource(s)/Data Source(s)

azurerm_logic_app_trigger_recurrence

Terraform Configuration Files

locals {
  xxx_logic_app = jsondecode(file("${path.module}/xxx_logic_app.json"))
}
resource "azurerm_logic_app_trigger_recurrence" "xxx_triggers_recurrence" {
  for_each     = { for t,v in local.xxx_logic_app.definition.triggers : t => v if v.type == "Recurrence" }
  name         = each.key
  logic_app_id = azurerm_logic_app_workflow.xxx.id
  frequency = each.value.recurrence.frequency
  interval = each.value.recurrence.interval
  start_time = each.value.recurrence.startTime
  time_zone = each.value.recurrence.timeZone
  # schedule {
  #   days_of_month = each.value.recurrence.schedule.MonthDays # Need to be supported
  # }
}

Debug Output/Panic Output

None captured

Expected Behaviour

When an existing reccurrence trigger is imported that is set up with monthDays then the resource should show changes to the schedule. eg with this trigger imported

        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Month",
                    "interval": 1,
                    "schedule": {
                        "monthDays": [
                            -1
                        ]
                    },
                    "startTime": "2024-08-01T00:00:00Z",
                    "timeZone": "GMT Standard Time"
                },
                "evaluatedRecurrence": {
                    "frequency": "Month",
                    "interval": 1,
                    "schedule": {
                        "monthDays": [
                            -1
                        ]
                    },
                    "startTime": "2024-08-01T00:00:00Z",
                    "timeZone": "GMT Standard Time"
                },
                "type": "Recurrence"
            }
        },

So if we assume we are changing the monthdays to [1, 10, 20]

  # azurerm_logic_app_trigger_recurrence.clearvue_triggers_recurrence["Recurrence"] will be updated in-place
  ~ resource "azurerm_logic_app_trigger_recurrence" "xxx_triggers_recurrence" {
        id           = "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Logic/workflows/xxxx/triggers/Recurrence"
        name         = "Recurrence"
        # (5 unchanged attributes hidden)

      - schedule {
        - no_of_days = [ -1 ] -> [ 1, 10, 20 ]
      -   }
    }

Actual Behaviour

When an existing reccurrence trigger is imported that is set up with monthDays then the resource does not show changes to the schedule - other than it will remove the schedule entirely. eg with this trigger imported

        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Month",
                    "interval": 1,
                    "schedule": {
                        "monthDays": [
                            -1
                        ]
                    },
                    "startTime": "2024-08-01T00:00:00Z",
                    "timeZone": "GMT Standard Time"
                },
                "evaluatedRecurrence": {
                    "frequency": "Month",
                    "interval": 1,
                    "schedule": {
                        "monthDays": [
                            -1
                        ]
                    },
                    "startTime": "2024-08-01T00:00:00Z",
                    "timeZone": "GMT Standard Time"
                },
                "type": "Recurrence"
            }
        },
  # azurerm_logic_app_trigger_recurrence.clearvue_triggers_recurrence["Recurrence"] will be updated in-place
  ~ resource "azurerm_logic_app_trigger_recurrence" "xxx_triggers_recurrence" {
        id           = "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.Logic/workflows/xxxx/triggers/Recurrence"
        name         = "Recurrence"
        # (5 unchanged attributes hidden)

      - schedule {}
    }

After applying the schedule is removed from the logic app.

Steps to Reproduce

No response

Important Factoids

No response

References

MicrosoftDocs/azure-docs#26707 shows that setting the monthDays to -1 is the last day of the month.

@Noel-Jones
Copy link
Contributor Author

I started to use this function because I was seeing drift with the custom function, but I have looked again at this. My json code is copied out of the console (sent from a third party) where it includes an element "evaluatedRecurrence". The Rest API does not return this so there is not a lot that Terraform could do to prevent the drift. However, if I take this out of the JSON myself then the drift issue is resolved.

resource "azurerm_logic_app_trigger_custom" "xxx_triggers" {
  # The rest API does not return the evaluatedReccurrence so this will cause drift. Remove it.
  for_each     = { for t,v in local.xxx_logic_app.definition.triggers : t => {for vk,vv in v : vk => vv if vk != "evaluatedRecurrence"} }
  name         = each.key
  logic_app_id = azurerm_logic_app_workflow.xxxx.id
  body         = jsonencode(each.value)
}

Given this I will be using the custom trigger resource going forward. It's easier in my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant