spacelift-io / terraform-provider-spacelift

Terraform provider to interact with Spacelift
MIT License
74 stars 28 forks source link

Scheduled task cron timestamp failure #485

Closed JamesWordie closed 10 months ago

JamesWordie commented 10 months ago

What resource has the issue? spacelift_scheduled_task

What is the issue? There is a provider bug with the scheduled task timestamp, On the spacelift portal (UI), I can create the following scheduled task cron timing. image However when I recreate this user terraform as below, I get an error.

resource "spacelift_scheduled_task" "rotate_app_reg_password" {
  for_each = toset(var.app_reg_password_rotate_names)
  stack_id = spacelift_stack.main.id

  command = "terraform apply -auto-approve -target=module.application[\\\"${each.value}\\\"].module.appregistration.random_password.service_principal_password -target=module.application[\\\"${each.value}\\\"].module.appregistration.azuread_service_principal_password.main -target=module.application[\\\"${each.value}\\\"].module.serviceconn.azuredevops_serviceendpoint_azurerm.serviceendpoint -target=module.application[\\\"${each.value}\\\"].azurerm_key_vault_secret.client_secret -replace=module.application[\\\"${each.value}\\\"].module.appregistration.random_password.service_principal_password"
  every   = ["0 8 * * 6#1"] # run every month on the 1st day of the month and run at 8am (9am GMT)
}

What is the error.

 Error: could not update scheduled task: invalid cron schedules: couldn't parse cron schedule expression '0 8 * * 6#1': failed to parse int from 6#1: strconv.Atoi: parsing "6#1": invalid syntax
│ 
│   with module.terraform-azure-stack["Investor Research and Emerging Technology - Dev/Test"].spacelift_scheduled_task.rotate_app_reg_password["bgbrain"],
│   on .terraform/modules/terraform-azure-stack/main.tf line 115, in resource "spacelift_scheduled_task" "rotate_app_reg_password":
│  115: resource "spacelift_scheduled_task" "rotate_app_reg_password" {
│ 
╵

Spacelift Provider Version 1.6.0

Comment If there is an alternative solution or suggestion (or a fix for this bug) it would be great to get this sorted out.

tomasmik commented 10 months ago

This is actually failing on the spacelift backend side. Frontend doesn't fully validate the string, that's why you're able to save it before creating the schedule in the UI.

I do not think there is anything to do here from the terraform provider side.