hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

[Bug]: aws_glue_trigger When try to update trigger its throws error InvalidInputException: Job cannot be a Predicate and Action for Conditional Trigger. #39571

Open vaquarkhan opened 2 weeks ago

vaquarkhan commented 2 weeks ago

Terraform Core Version

1.5.4

AWS Provider Version

5.61.0

Affected Resource(s)

I am running Glue trigger and when apply first time will work as expected but when i am running same again it should skip changes as same trigger already deployed or override but i am getting following error

module.glue_trigger.aws_glue_trigger.default[0]: Modifying... [id=glue-job-trigger-2]
╷
│ Error: updating Glue Trigger (glue-job-trigger-2): operation error Glue: UpdateTrigger, https response error StatusCode: 400, RequestID: abbdba6f-86e5-4239-9a8b-2db432321b76, InvalidInputException: Job cannot be a Predicate and Action for Conditional Trigger.
│
│   with module.glue_trigger.aws_glue_trigger.default[0],
│   on ..\..\main.tf line 1, in resource "aws_glue_trigger" "default":
│    1: resource "aws_glue_trigger" "default" {
│

Expected Behavior

Will save no change found in configuration or update same without error

Actual Behavior

Throwing error

│ Error: updating Glue Trigger (glue-job-trigger-2): operation error Glue: UpdateTrigger, https response error StatusCode: 400, RequestID: abbdba6f-86e5-4239-9a8b-2db432321b76, InvalidInputException: Job cannot be a Predicate and Action for Conditional Trigger.

Relevant Error/Panic Output Snippet

terraform apply
module.glue_trigger.aws_glue_trigger.default[0]: Refreshing state... [id=glue-job-trigger-2]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.glue_trigger.aws_glue_trigger.default[0] will be updated in-place
  ~ resource "aws_glue_trigger" "default" {
        id                = "glue-job-trigger-2"
        name              = "glue-job-trigger-2"
        tags              = {}
        # (8 unchanged attributes hidden)

      + predicate {
          + logical = "AND"

          + conditions {
              + job_name         = "glueJob01CBE81D-QUZVpWC00kZS"
              + logical_operator = "EQUALS"
              + state            = "SUCCEEDED"
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.glue_trigger.aws_glue_trigger.default[0]: Modifying... [id=glue-job-trigger-2]
╷
│ Error: updating Glue Trigger (glue-job-trigger-2): operation error Glue: UpdateTrigger, https response error StatusCode: 400, RequestID: abbdba6f-86e5-4239-9a8b-2db432321b76, InvalidInputException: Job cannot be a Predicate and Action for Conditional Trigger.
│
│   with module.glue_trigger.aws_glue_trigger.default[0],
│   on ..\..\main.tf line 1, in resource "aws_glue_trigger" "default":
│    1: resource "aws_glue_trigger" "default" {
│

Terraform Configuration Files

resource "aws_glue_trigger" "default" {

  count = var.enable_glue_trigger ? 1 : 0

  name               = var.trigger_name
  description        = var.description
  type               = var.trigger_type
  schedule           = var.schedule
  start_on_creation  = var.start_on_creation
  workflow_name      = var.workflow_name

  actions {
    job_name       = var.job_name
    arguments      = var.job_arguments
    timeout        = var.job_timeout
    notification_property {
      notify_delay_after = var.notify_delay_after
    }
  }

  predicate {
    logical = var.predicate_logical

    conditions {
      logical_operator = var.condition_logical_operator
      job_name         = var.condition_job_name
      state            = var.condition_state
      crawler_name     = var.condition_crawler_name
      crawl_state      = var.condition_crawl_state
    }
  }
}

Steps to Reproduce

Debug Output

Shared above

Panic Output

No response

Important Factoids

This issue not related to IAM as i tried with admin access and restrict access , error would be same .

References

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/glue_trigger

Would you like to implement a fix?

Yes

github-actions[bot] commented 2 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

vaquarkhan commented 2 weeks ago

Logs

terraform apply
module.glue_trigger.aws_glue_trigger.default[0]: Refreshing state... [id=glue-job-trigger-2]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.glue_trigger.aws_glue_trigger.default[0] will be created

  + resource "aws_glue_trigger" "default" {
      + arn               = (known after apply)
      + description       = "An example Glue trigger."
      + enabled           = true
      + id                = (known after apply)
      + name              = "glue-job-trigger-2"
      + schedule          = "cron(0 12 * * ? *)"
      + start_on_creation = true
      + state             = (known after apply)
      + tags_all          = (known after apply)
      + type              = "SCHEDULED"

      + actions {
          + job_name = "glueJob01CBE81D-QUZVpWC00kZS"
          + timeout  = 60

          + notification_property {
              + notify_delay_after = 5
            }
        }

      + predicate {
          + logical = "AND"

          + conditions {
              + job_name         = "glueJob01CBE81D-QUZVpWC00kZS"
              + logical_operator = "EQUALS"
              + state            = "SUCCEEDED"
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.glue_trigger.aws_glue_trigger.default[0]: Creating...
module.glue_trigger.aws_glue_trigger.default[0]: Creation complete after 1s [id=glue-job-trigger-2]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

----------------------------------------------------------------
$ terraform apply
module.glue_trigger.aws_glue_trigger.default[0]: Refreshing state... [id=glue-job-trigger-2]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.glue_trigger.aws_glue_trigger.default[0] will be updated in-place
  ~ resource "aws_glue_trigger" "default" {
        id                = "glue-job-trigger-2"
        name              = "glue-job-trigger-2"
      ~ schedule          = "cron(00 12 * * ? *)" -> "cron(0 12 * * ? *)"
        tags              = {}
        # (7 unchanged attributes hidden)

      + predicate {
          + logical = "AND"

          + conditions {
              + job_name         = "glueJob01CBE81D-QUZVpWC00kZS"
              + logical_operator = "EQUALS"
              + state            = "SUCCEEDED"
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.glue_trigger.aws_glue_trigger.default[0]: Modifying... [id=glue-job-trigger-2]
╷
│ Error: updating Glue Trigger (glue-job-trigger-2): operation error Glue: UpdateTrigger, https response error StatusCode: 400, RequestID: 65f9876e-2ab7-4b58-b71a-bbe699739d50, InvalidInputException: Job cannot be a Predicate and Action for Conditional Trigger.
│
│   with module.glue_trigger.aws_glue_trigger.default[0],
│   on ..\..\main.tf line 1, in resource "aws_glue_trigger" "default":
│    1: resource "aws_glue_trigger" "default" {
│