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.61k stars 9k forks source link

[Bug]: Error: Provider produced inconsistent final plan #36749

Open codingeologist opened 3 months ago

codingeologist commented 3 months ago

Terraform Core Version

1.5.6

AWS Provider Version

5.44.0

Affected Resource(s)

aws_s3_object

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

Expected Behavior

the S3 object is updated with the new zip

Actual Behavior

Error: Provider produced inconsistent final plan

When expanding the plan for aws_s3_object.lambda_layer_zip to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .source_hash: was cty.StringVal("07c85e56ddc28dc9cce82b0bfbbbed1d"), but now cty.StringVal("7e13c0bd39bc458c553f0c9b76b0a313").

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

Relevant Error/Panic Output Snippet

Error: Provider produced inconsistent final plan

When expanding the plan for aws_s3_object.lambda_layer_zip to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .source_hash: was cty.StringVal("07c85e56ddc28dc9cce82b0bfbbbed1d"), but now cty.StringVal("7e13c0bd39bc458c553f0c9b76b0a313").

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

Terraform Configuration Files

resource "aws_s3_object" "lambda_layer_zip" {
  bucket      = aws_s3_bucket.lambda_layer.id
  key         = "lambda-layers/${local.layer_name}/${local.layer_zip_name}"
  source      = local.layer_zip_name
  source_hash = "${filemd5(local.layer_zip_name)}"
}

resource "aws_lambda_layer_version" "lambda_layer" {
  s3_bucket           = aws_s3_bucket.lambda_layer.id
  s3_key              = aws_s3_object.lambda_layer_zip.key
  layer_name          = local.layer_name
  compatible_runtimes = ["python3.9"]
  skip_destroy        = false
  source_code_hash    = "${filebase64sha256(local.layer_zip_name)}"
  depends_on          = [aws_s3_object.lambda_layer_zip]
}

Steps to Reproduce

create s3 object with a zip file to be updated with a new zip file on terraform apply

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 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

p-fuchs commented 3 months ago

I think not only s3 creation is impacted, I've encountered this with batch_job / aws_cloudwatch_event_target

β”‚ Error: Provider produced inconsistent final plan
β”‚
β”‚ When expanding the plan for aws_cloudwatch_event_target.<job_name>
β”‚ 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:<region>:<number>:job-definition/<job_name>:1088"),
β”‚ but now
β”‚ cty.StringVal("arn:aws:batch:<region>:<number>:job-definition/<job_name>:1089")
hazmei commented 2 months ago

Got the same issue as well on terraform 1.8.1 aws provider version 5.46.0.

Error: Provider produced inconsistent final plan
When expanding the plan for module.this.module.lambda.aws_lambda_function.this[0] to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .source_code_hash: was cty.StringVal("41wsmvoFXOT5wephygDO95Fk44MixQfMPKmR4yPnqco="), but now cty.StringVal("8EqPeruhgrPSBwr7J8dcMo5Y3/em/qBwim8ixAOlmbs=").

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

Using https://github.com/terraform-aws-modules/terraform-aws-notify-slack terraform module.

ebrassell commented 1 month ago

I encountered the same and was able to workaround by pinning to version "5.43.0"

umiddey commented 2 days ago

Facing the same issue. None of the solutions here work. Is there any update on this? It is really important :(