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.87k stars 9.21k forks source link

[Bug]: aws_batch_job_definition errors out in aws provider version 5.67 #39443

Open raul-gherman-modaoperandi opened 2 months ago

raul-gherman-modaoperandi commented 2 months ago

Terraform Core Version

1.9.5

AWS Provider Version

5.67

Affected Resource(s)

Expected Behavior

terraform apply runs to completion

Actual Behavior

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for aws_cloudwatch_event_target.search-api-hard_reindex_list_indexes_target[0] to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .batch_target[0].job_definition: was cty.StringVal("arn:aws:batch:*********:923133779345:job-definition/search-api-hard-reindex-list-indexes-staging:6"), but now cty.StringVal("arn:aws:batch:*********:923133779345:job-definition/search-api-hard-reindex-list-indexes-staging:7").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Exited with code exit status 1

Relevant Error/Panic Output Snippet

╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for aws_cloudwatch_event_target.search-api-hard_reindex_list_indexes_target[0] to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .batch_target[0].job_definition: was cty.StringVal("arn:aws:batch:*********:923133779345:job-definition/search-api-hard-reindex-list-indexes-staging:6"), but now cty.StringVal("arn:aws:batch:*********:923133779345:job-definition/search-api-hard-reindex-list-indexes-staging:7").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Exited with code exit status 1

Terraform Configuration Files

// Job Definition
resource "aws_batch_job_definition" "search-api" {
  name                       = "search-api-hard-reindex-list-indexes-${local.env}"
  type                       = "container"
  container_properties       = templatefile("/root/tf-project/infrastructure/search-service/batch/templates/search-api-batch_container-${local.env}.tpl", {})
  deregister_on_new_revision = false
}

//------------ Schedules

resource "aws_cloudwatch_event_rule" "search-api-hard_reindex_list_indexes_rule" {
  name                = "search-api-hard_reindex_list_indexes_rule-${local.env}"
  description         = "batch run hard reindex list indexes rake task for ${local.env}"
  schedule_expression = "cron(30 8 * * ? *)"
}

resource "aws_cloudwatch_event_target" "search-api-hard_reindex_list_indexes_target" {
  rule      = aws_cloudwatch_event_rule.search-api-hard_reindex_list_indexes_rule.name
  target_id = "search-api-hard-reindex-list-indexes_rule-${local.env}"
  arn       = aws_batch_job_queue.search-api.arn
  role_arn  = aws_iam_role.batch_events.arn
  count     = "1"

  batch_target {
    job_definition = aws_batch_job_definition.search-api.arn
    job_name       = aws_batch_job_definition.search-api.name
    job_attempts   = 1
  }
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

LucaIcaro commented 2 months ago

having a similar problem with core v1.6.6 and provider 5.68

module.cluster-batch.module.launch_template["cluster-v1"].aws_launch_template.this: Modifying... [id=lt-YYYYYYYYY]
module.cluster-batch.module.launch_template["cluster-v1"].aws_launch_template.this: Modifications complete after 1s [id=lt-XXXXXXXXXXXX]

Error: Provider produced inconsistent final plan

When expanding the plan for
module.cluster-batch.aws_batch_compute_environment.this["cluster-v1"]
to include new values learned so far during apply, provider
"registry.terraform.io/hashicorp/aws" changed the planned action from Update
to DeleteThenCreate.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Error: Provider produced inconsistent final plan
justinretzolk commented 1 month ago

@LucaIcaro 👋 It looks like your error is for aws_batch_compute_environment, while this issue pertains to aws_cloudwatch_event_target, and the error is slightly different. So that your report doesn't get lost, I'd recommend opening a new issue.