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

aws_batch_job_definition with empty env var generates unexpected diff on each tf apply (guaranteed reproduction😉) #26960

Closed
Veetaha opened this issue Sep 23, 2022 · 3 comments · Fixed by #29820
Assignees
Labels
bug Addresses a defect in current functionality. service/batch Issues and PRs that pertain to the batch service.
Milestone

Comments

@Veetaha
Copy link
Contributor

Veetaha commented Sep 23, 2022

Terraform Core Version

1.3.0

AWS Provider Version

4.31.0

Affected Resource(s)

  • aws_batch_job_definition

Expected Behavior

There is no diff generated when doing tf apply if there were no changes to the resource at all.

Actual Behavior

tf apply generates a diff:

$ tf apply
aws_batch_job_definition.blackjack: Refreshing state... [id=arn:aws:batch:us-east-2:{REDACTED_ACCOUNT_ID}:job-definition/blackjack:3]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_batch_job_definition.blackjack must be replaced
-/+ resource "aws_batch_job_definition" "blackjack" {
      ~ arn                   = "arn:aws:batch:us-east-2:{REDACTED_ACCOUNT_ID}:job-definition/blackjack:3" -> (known after apply)
      ~ container_properties  = jsonencode(
          ~ {
              - command                      = [] -> null
              ~ environment                  = [
                  + {
                      + name  = "FOO"
                      + value = ""
                    },
                    {
                        name  = "BAR"
                        value = "filled"
                    },
                ]
              - fargatePlatformConfiguration = {
                  - platformVersion = "LATEST"
                } -> null
              - mountPoints                  = [] -> null
              - secrets                      = [] -> null
              - ulimits                      = [] -> null
              - volumes                      = [] -> null
                # (4 unchanged elements hidden)
            } # forces replacement
        )
      ~ id                    = "arn:aws:batch:us-east-2:{REDACTED_ACCOUNT_ID}:job-definition/blackjack:3" -> (known after apply)
        name                  = "blackjack"
      - parameters            = {} -> null
      ~ revision              = 3 -> (known after apply)
        tags                  = {
            "elastio:resource" = "true"
        }
        # (4 unchanged attributes hidden)
    }

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

Terraform Configuration Files

resource "aws_batch_job_definition" "blackjack" {
  name                  = "blackjack"
  type                  = "container"
  platform_capabilities = ["FARGATE"]
  container_properties  = <<JOB_DEFINITION
  {
    "image": "public.ecr.aws/elastio-dev/elastio-bg-job:0.19.21-amd64",
    "environment": [
        { "name": "FOO", "value": "" },
        { "name": "BAR", "value": "filled" }
    ],
    "jobRoleArn": "{REDACTED}",
    "executionRoleArn": "{REDACTED},
    "resourceRequirements": [
      { "type": "VCPU", "value": "4" },
      { "type": "MEMORY", "value": "12288" }
    ]
  }
  JOB_DEFINITION

  tags = {
    "elastio:resource" = "true"
  }
}

Steps to Reproduce

  1. Copy-paste the terraform configuration file above to main.tf
  2. Insert valid job role arn and execution role arn in places for redacted fields.
  3. tf init
  4. tf apply -auto-approve
  5. tf apply, here you will see that there is a diff

Debug Output

I wouldn't like to share the TF_LOG=debug, since it may contain sensitive information. The problem is easily reproducible, so it's not very important.

@Veetaha Veetaha added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Sep 23, 2022
@github-actions
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.

@github-actions github-actions bot added service/batch Issues and PRs that pertain to the batch service. and removed bug Addresses a defect in current functionality. labels Sep 23, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 28, 2022
@gdavison gdavison self-assigned this Mar 6, 2023
@github-actions github-actions bot added this to the v4.58.0 milestone Mar 7, 2023
@github-actions
Copy link

This functionality has been released in v4.58.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!

@github-actions
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 Apr 11, 2023
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. service/batch Issues and PRs that pertain to the batch service.
Projects
None yet
3 participants