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

[Bug]: aws_batch_job_definition: After updating the resource the revision, id and arn attributes still show the previous revision #36824

Closed
fergoid opened this issue Apr 10, 2024 · 9 comments · Fixed by #37111
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/batch Issues and PRs that pertain to the batch service.
Milestone

Comments

@fergoid
Copy link
Contributor

fergoid commented Apr 10, 2024

Same as #36865
Relates to #36894
Results from #35149?

Terraform Core Version

1.7.5

AWS Provider Version

5.44.0

Affected Resource(s)

  • aws_batch_job_definition

Expected Behavior

Each update to the job definition created a new revision of the job definition and the attributes should reflect the new revision not the previous one. For example we would use the ARN attribute in an EventBridge target and we want to update that to target the latest active revision.

This worked correctly in v5.43.0, it looks like something may have changed on the back of the introduction of [deregister_on_new_revision] in 5.44?(https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/batch_job_definition#deregister_on_new_revision)

Actual Behavior

  • Create a new job definition and revision, ARN and Id attributes will show revision 1 as expected
  • Update the resource and all of the attributes still show revision 1 even though the active resource is now at revision 2.
  • Running a subsequent Terraform plan returns the correct revision.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_batch_job_definition" "test" {
  name = "${terraform.workspace}-foo"
  type = "container"
  container_properties = jsonencode({
    command = ["ls", "-la"],
    image   = "busybox"

    resourceRequirements = [
      {
        type  = "VCPU"
        value = "1"
      },
      {
        type  = "MEMORY"
        value = "512"
      }
    ]

    volumes = [
      {
        host = {
          sourcePath = "/tmp"
        }
        name = "tmp"
      }
    ]

    environment = [
      {
        name  = "VARNAME"
        value = "VARVAL"
      }
    ]

    mountPoints = [
      {
        sourceVolume  = "tmp"
        containerPath = "/tmp"
        readOnly      = false
      }
    ]

    ulimits = [
      {
        hardLimit = 1024
        name      = "nofile"
        softLimit = 1024
      }
    ]
  })
}

output arn {
  value = aws_batch_job_definition.test.arn
}

output id {
  value = aws_batch_job_definition.test.id
}

output revision {
  value = aws_batch_job_definition.test.revision
}

Steps to Reproduce

  • Plan/apply an aws_batch_job_definition with outputs for id, ARN and id. The outputs will be showing revision 1.
  • Update the resource (one which does not force new, I was updating the command flipping between 'ls -la' and 'ls -lah') with plan/apply and outputs will still be showing revision 1 event though the active resource in AWS is now revision 2.
  • Run another plan and the outputs will now show revision 2

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

@fergoid fergoid added the bug Addresses a defect in current functionality. label Apr 10, 2024
@github-actions github-actions bot added the service/batch Issues and PRs that pertain to the batch service. label Apr 10, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 10, 2024
@theriault
Copy link

theriault commented Apr 11, 2024

Potentially related - the tags_all appear to not get applied on the new revision as well and it requires a rerun for it to add them.

First apply:

tags                       = {}

Second apply:

      ~ tags_all                   = {
          + "Environment" = "dev"
          + "Team"        = "example"
          + "Terraform"   = "true"
        }

@justinretzolk justinretzolk added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Apr 15, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 15, 2024
@MDBox
Copy link

MDBox commented Apr 15, 2024

I am also getting this bug. It seems that in version 5.43.0 it does forces replacement but in later versions it does an update in-place change.

@fergoid
Copy link
Contributor Author

fergoid commented Apr 17, 2024

Just looking at this again, from what I can see the ARN, id & revision attributes in the state are correct after an update but the ARN, id and revision outputs still reflect the previous revision.

@epgui
Copy link

epgui commented Apr 17, 2024

I am also seeing this in 5.45.0.

@PaulDMendoza
Copy link

PaulDMendoza commented Apr 24, 2024

I'm also seeing this issue in 5.46.0

Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.47.0 milestone Apr 25, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 26, 2024
Copy link

This functionality has been released in v5.47.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/batch Issues and PRs that pertain to the batch service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants