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]: Error: Provider produced inconsistent final plan - AWS Batch Job Definition #36894

Closed
jkh19 opened this issue Apr 12, 2024 · 6 comments · Fixed by #37111
Closed

[Bug]: Error: Provider produced inconsistent final plan - AWS Batch Job Definition #36894

jkh19 opened this issue Apr 12, 2024 · 6 comments · Fixed by #37111
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. service/iam Issues and PRs that pertain to the iam service. service/lambda Issues and PRs that pertain to the lambda service. service/sts Issues and PRs that pertain to the sts service.
Milestone

Comments

@jkh19
Copy link

jkh19 commented Apr 12, 2024

Relates to #36824, #36865?
Results from #35149?

Terraform Core Version

1.7.2

AWS Provider Version

5.45.0

Affected Resource(s)

aws_batch_job_definition

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

Expected Behavior

Deployment with updates to aws_batch_job_definition resource should succeed.

Actual Behavior

│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for aws_lambda_function.imdb to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for
│ .environment[0].variables["JobDefinition"]: was cty.StringVal("arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:2"), but now
│ cty.StringVal("arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:3").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_iam_role" "my_role" {
  name = "my-iam-role"
}

data "aws_caller_identity" "current" {}

resource "aws_batch_job_definition" "batch_job_definition" {
  name = "test-job-definition"
  type = "container"
  platform_capabilities = ["FARGATE"]

  container_properties = jsonencode({
    image   = "${data.aws_caller_identity.current.account_id}.dkr.ecr.us-east-1.amazonaws.com/test-image:1"

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

    executionRoleArn = data.aws_iam_role.my_role.arn
  })
}

resource "aws_lambda_function" "my_lambda" {
  filename      = "my-lambda.zip"
  function_name = "test-lambda-function"
  role          = data.aws_iam_role.my_role.arn
  handler       = "Function::FunctionHandler"
  runtime       = "dotnet8"
  publish       = true

  environment {
    variables = {      
      JobDefinition = aws_batch_job_definition.batch_job_definition.arn
    }
  }

  depends_on = [aws_batch_job_definition.batch_job_definition]
}

Steps to Reproduce

  • On initial deployment, 2 resources will be added and the deployment succeeds.
  • Update the tag on the image from test-image:1 to test-image:2 to modify the aws_batch_job_definition.
    • Only one resource will be updated even though this operation will create a new version of the job definition.
      # aws_batch_job_definition.batch_job_definition will be updated in-place
    ~ resource "aws_batch_job_definition" "batch_job_definition" {
      ~ container_properties       = jsonencode(
          ~ {
              - command                      = [] -> null
              - environment                  = [] -> null
              - fargatePlatformConfiguration = {
                  - platformVersion = "LATEST"
                } -> null
              ~ image                        = "123456789012.dkr.ecr.us-east-1.amazonaws.com/test-image:1" -> "123456789012.dkr.ecr.us-east-1.amazonaws.com/test-image:2"
              - mountPoints                  = [] -> null
              - secrets                      = [] -> null
              - ulimits                      = [] -> null
              - volumes                      = [] -> null
                # (2 unchanged elements hidden)
            }
        )
        id                         = "arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:1"
        name                       = "test-job-definition"
        tags                       = {}
        # (10 unchanged attributes hidden)
    }
    
    Plan: 0 to add, 1 to change, 0 to destroy.
    
  • Update the tag on the image from test-image:2 to test-image:3 to modify the aws_batch_job_definition.
    • Two resources will show as modified, but the lambda function is getting bumped to the version of the job definition created in the previous step.
    # aws_batch_job_definition.batch_job_definition will be updated in-place
    ~ resource "aws_batch_job_definition" "batch_job_definition" {
     ~ container_properties       = jsonencode(
         ~ {
             - command                      = [] -> null
             - environment                  = [] -> null
             - fargatePlatformConfiguration = {
                 - platformVersion = "LATEST"
               } -> null
             ~ image                        = "123456789012.dkr.ecr.us-east-1.amazonaws.com/test-image:2" -> "123456789012.dkr.ecr.us-east-1.amazonaws.com/test-image:3"
             - mountPoints                  = [] -> null
             - secrets                      = [] -> null
             - ulimits                      = [] -> null
             - volumes                      = [] -> null
               # (2 unchanged elements hidden)
           }
       )
       id                         = "arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:2"
       name                       = "test-job-definition"
       tags                       = {}
       # (10 unchanged attributes hidden)
    }
    
    # aws_lambda_function.my_lambda will be updated in-place
    ~ resource "aws_lambda_function" "my_lambda" {
       id                             = "test-lambda-function"
     ~ qualified_arn                  = "arn:aws:lambda:us-east-1:123456789012:function:test-lambda-function:1" -> (known after apply)
     ~ qualified_invoke_arn           = "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:test-lambda-function:1/invocations" -> (known after apply)    
       tags                           = {}
     ~ version                        = "1" -> (known after apply)
       # (19 unchanged attributes hidden)
    
     ~ environment {
         ~ variables = {
             ~ "JobDefinition" = "arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:1" -> "arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:2"
           }
       }
    
    
    
       # (3 unchanged blocks hidden)
    }
    
    Plan: 0 to add, 2 to change, 0 to destroy.
    
    aws_batch_job_definition.batch_job_definition: Modifying... [id=arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:2]
    aws_batch_job_definition.batch_job_definition: Modifications complete after 1s [id=arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:3]
    ╷
    │ Error: Provider produced inconsistent final plan
    │ 
    │ When expanding the plan for aws_lambda_function.my_lambda to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for
    │ .environment[0].variables["JobDefinition"]: was cty.StringVal("arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:2"), but now
    │ cty.StringVal("arn:aws:batch:us-east-1:123456789012:job-definition/test-job-definition:3").
    │ 
    │ This is a bug in the provider, which should be reported in the provider's own issue tracker.
    

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@jkh19 jkh19 added the bug Addresses a defect in current functionality. label Apr 12, 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.

@github-actions github-actions bot added service/batch Issues and PRs that pertain to the batch service. service/iam Issues and PRs that pertain to the iam service. service/lambda Issues and PRs that pertain to the lambda service. service/sts Issues and PRs that pertain to the sts service. labels Apr 12, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 12, 2024
@justinretzolk justinretzolk removed service/lambda Issues and PRs that pertain to the lambda service. service/iam Issues and PRs that pertain to the iam service. service/sts Issues and PRs that pertain to the sts service. needs-triage Waiting for first response or review from a maintainer. labels Apr 15, 2024
@kharigardner
Copy link

Bumping this as a issue -> running into this with CDKTF (v0.20.3) (Terraform v1.5.5) as well, sometimes it will raise this error but sometimes the resources get created with an invalid job definition version, leading to silent issues with using the output of the JobDefinition ARN in resources like EventBridge Schedule Targets

@dpassassin
Copy link

#36824
#36865

@github-actions github-actions bot added service/iam Issues and PRs that pertain to the iam service. service/lambda Issues and PRs that pertain to the lambda service. service/sts Issues and PRs that pertain to the sts service. labels Apr 23, 2024
@YakDriver YakDriver added the regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. label Apr 23, 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 23, 2024
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. service/iam Issues and PRs that pertain to the iam service. service/lambda Issues and PRs that pertain to the lambda service. service/sts Issues and PRs that pertain to the sts service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants