terraform-provider-yandex icon indicating copy to clipboard operation
terraform-provider-yandex copied to clipboard

Error Creating Timer Trigger for Container in Yandex Cloud via Terraform (v0.127.0)

Open jaasco opened this issue 4 months ago • 0 comments

Current Version: 0.127.0

Issue Description: According to the documentation, it's possible to create a timer trigger for a container. Using the Yandex Cloud web console it works, but when attempting to create the same trigger using Terraform, an error occurs during deployment.

Steps to Reproduce:

  1. In main.tf, add the following resource:
resource "yandex_function_trigger" "my_trigger" {
  folder_id = var.folder_id
  name      = "my-trigger-name"
  timer {
    cron_expression = "*/15 * ? * * *"
  }
  container {
    id                = container-resource-id
    service_account_id = service-account-id
  }
}
  1. Deploy using Terraform.

Actual

Error: Error while requesting API to create Yandex Cloud Functions Trigger: server-request-id = 1fe58960-c096-4df9-a4db-9e6041316c66 server-trace-id = af9373efb21439cb:9012fe4256058203:af9373efb21439cb:1 client-request-id = 74bab5eb-04c2-434b-b7c8-ea5d98aebbe8 client-trace-id = 87829d54-93dd-4cc2-b37c-450da2a3be81 rpc error: code = InvalidArgument desc = Validation failed:
  - rule.timer.invoke_function.function_id: Field is required

Expected A timer trigger should be created for the specified container without any errors.

Relative code

It seems that the error appears here:

		if retrySettings != nil || dlqSettings != nil {
			if invokeType == "function" {
				timer.Action = &triggers.Trigger_Timer_InvokeFunctionWithRetry{
					InvokeFunctionWithRetry: getInvokeFunctionWithRetry(),
				}
			} else if invokeType == "container" {
				timer.Action = &triggers.Trigger_Timer_InvokeContainerWithRetry{
					InvokeContainerWithRetry: getInvokeContainerWithRetry(),
				}
			}
		} else {
			timer.Action = &triggers.Trigger_Timer_InvokeFunction{
				InvokeFunction: getInvokeFunctionOnce(),
			}
		}

The else-clause does not account for the case when invokeType is "container", so without the "retry" or "dlq" settings, it only works for functions.

jaasco avatar Oct 08 '24 09:10 jaasco