-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Error: Provider produced inconsistent final plan #17884
Comments
Hi @intechops6 👋 Thank you for reporting this and sorry you ran into trouble here. Could you please provide us with some additional information so we can look into this further?
|
I am seeing the same issue with
The underlying file
should not change (it's an archive). The archive content does not change, but I see the modification timestamp on the file is changed every time I run The archive is defined as
|
I've just bumped into the same issue at |
Hi @bflad, I have encountered the same issue recently.
The Terraform AWS Provider version is 3.37.0 linux amd64. Here is the output of terraform plan below.
|
Same here! data "aws_s3_bucket_object" "create_r53_cname_hash" {
bucket = aws_s3_bucket.lambdas.bucket
key = trimprefix(yamldecode(file("/tmp/create-route53-cname.yml"))["Resources"]["Function"]["Properties"]["CodeUri"], "s3://${aws_s3_bucket.lambdas.bucket}/")
depends_on = [null_resource.upload_create_r53_lambda]
}
resource "null_resource" "upload_create_r53_lambda" {
triggers = {
function_contents = filemd5("${path.module}/../../../lambda/create-route53-cname/function.py")
}
provisioner "local-exec" {
command = <<EOF
sam package --s3-bucket ${aws_s3_bucket.lambdas.bucket} --s3-prefix CreateRoute53CNAME \
-t ${path.module}/../../../lambda/create-route53-cname/template.yml \
--debug --region ${data.aws_region.current.name} \
--output-template-file /tmp/create-route53-cname.yml
EOF
}
depends_on = [aws_s3_bucket.lambdas]
}
resource "aws_lambda_function" "create_r53_cname" {
function_name = "CreateRoute53CNAME"
role = aws_iam_role.route53_lambda.arn
s3_bucket = aws_s3_bucket.lambdas.bucket
s3_key = data.aws_s3_bucket_object.create_r53_cname_hash.key
source_code_hash = data.aws_s3_bucket_object.create_r53_cname_hash.body
handler = "function.lambda_handler"
runtime = "python3.8"
environment {
variables = {
ENV = terraform.workspace
}
}
tags = local.global_tags
depends_on = [null_resource.upload_create_r53_lambda, data.aws_s3_bucket_object.create_r53_cname_hash]
} PLAN ❯ tf plan -target data.aws_iam_policy_document.trust_lambda -target data.aws_region.current -target data.aws_s3_bucket_object.create_r53_cname_hash -target aws_iam_role.route53_lambda -target aws_lambda_function.create_r53_cname -target aws_s3_bucket.lambdas -target null_resource.upload_create_r53_lambda -out lambda.tf.plan
aws_s3_bucket.lambdas: Refreshing state... [id=policymap-lambdas20210512022937079100000002]
aws_iam_role.route53_lambda: Refreshing state... [id=terraform-20210512022937078800000001]
null_resource.upload_create_r53_lambda: Refreshing state... [id=3423314569226036676]
aws_lambda_function.create_r53_cname: Refreshing state... [id=CreateRoute53CNAME]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
-/+ destroy and then create replacement
<= read (data resources)
Terraform will perform the following actions:
# data.aws_s3_bucket_object.create_r53_cname_hash will be read during apply
# (config refers to values not yet known)
<= data "aws_s3_bucket_object" "create_r53_cname_hash" {
+ body = (known after apply)
~ bucket_key_enabled = false -> (known after apply)
+ cache_control = (known after apply)
+ content_disposition = (known after apply)
+ content_encoding = (known after apply)
+ content_language = (known after apply)
~ content_length = 9076 -> (known after apply)
~ content_type = "binary/octet-stream" -> (known after apply)
~ etag = "0c1996e47e57b8b25003ae534b603fb5" -> (known after apply)
+ expiration = (known after apply)
+ expires = (known after apply)
~ id = "policymap-lambdas20210512022937079100000002/CreateRoute53CNAME/56341e34fd3536312881cd0f2aa2aa6a" -> (known after apply)
~ last_modified = "Wed, 12 May 2021 02:47:12 UTC" -> (known after apply)
~ metadata = {} -> (known after apply)
+ object_lock_legal_hold_status = (known after apply)
+ object_lock_mode = (known after apply)
+ object_lock_retain_until_date = (known after apply)
~ server_side_encryption = "AES256" -> (known after apply)
+ sse_kms_key_id = (known after apply)
~ storage_class = "STANDARD" -> (known after apply)
~ tags = {} -> (known after apply)
+ version_id = (known after apply)
+ website_redirect_location = (known after apply)
# (2 unchanged attributes hidden)
}
# aws_lambda_function.create_r53_cname will be updated in-place
~ resource "aws_lambda_function" "create_r53_cname" {
id = "CreateRoute53CNAME"
~ last_modified = "2021-05-12T02:53:49.507+0000" -> (known after apply)
~ source_code_hash = "748Qi76r0AcDuO4raBpUGlY6D/n1ULX7NUgfO64SyOQ=" -> (known after apply)
tags = {
"Terraform" = "true"
"Terraform.Workspace" = "default"
}
# (17 unchanged attributes hidden)
# (2 unchanged blocks hidden)
}
# null_resource.upload_create_r53_lambda must be replaced
-/+ resource "null_resource" "upload_create_r53_lambda" {
~ id = "3423314569226036676" -> (known after apply)
~ triggers = { # forces replacement
~ "function_contents" = "07932e6eb48fe68ae84d74e5b9e9f246" -> "2702955807b7396a566ff4caed2e7e09"
}
}
Plan: 1 to add, 1 to change, 1 to destroy.
Changes to Outputs:
~ create_r53_cname_hash = {
~ body = null -> (known after apply)
~ bucket_key_enabled = false -> (known after apply)
~ cache_control = "" -> (known after apply)
~ content_disposition = "" -> (known after apply)
~ content_encoding = "" -> (known after apply)
~ content_language = "" -> (known after apply)
~ content_length = 9076 -> (known after apply)
~ content_type = "binary/octet-stream" -> (known after apply)
~ etag = "0c1996e47e57b8b25003ae534b603fb5" -> (known after apply)
~ expiration = "" -> (known after apply)
~ expires = "" -> (known after apply)
~ id = "policymap-lambdas20210512022937079100000002/CreateRoute53CNAME/56341e34fd3536312881cd0f2aa2aa6a" -> (known after apply)
~ last_modified = "Wed, 12 May 2021 02:47:12 UTC" -> (known after apply)
~ metadata = {} -> (known after apply)
~ object_lock_legal_hold_status = "" -> (known after apply)
~ object_lock_mode = "" -> (known after apply)
~ object_lock_retain_until_date = "" -> (known after apply)
~ server_side_encryption = "AES256" -> (known after apply)
~ sse_kms_key_id = "" -> (known after apply)
~ storage_class = "STANDARD" -> (known after apply)
~ tags = {} -> (known after apply)
~ version_id = "" -> (known after apply)
~ website_redirect_location = "" -> (known after apply)
# (3 unchanged elements hidden)
}
╷
│ Warning: Resource targeting is in effect
│
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
╵ APPLY ❯ tf apply lambda.tf.plan
null_resource.upload_create_r53_lambda: Destroying... [id=3423314569226036676]
null_resource.upload_create_r53_lambda: Destruction complete after 0s
null_resource.upload_create_r53_lambda: Creating...
null_resource.upload_create_r53_lambda: Provisioning with 'local-exec'...
null_resource.upload_create_r53_lambda (local-exec): Executing: ["/bin/sh" "-c" "sam package --s3-bucket policymap-lambdas20210512022937079100000002 --s3-prefix CreateRoute53CNAME \\\n-t ./../../../lambda/create-route53-cname/template.yml \\\n--debug --region us-east-1 \\\n--output-template-file /tmp/create-route53-cname.yml\n"]
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:14,528 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:14,528 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:14,529 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId': '262ab576-5ad0-4dd8-9098-728df1af6301', 'installationId': '7f3eb4fa-f246-4b4b-8c50-0edcd0151638', 'sessionId': '61b345d2-7773-4118-81ee-21943b4ec77f', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.9', 'samcliVersion': '1.22.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': 'us-east-1', 'warningName': 'CodeDeployWarning', 'warningCount': 0}}]}
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,023 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,024 | Sending Telemetry: {'metrics': [{'templateWarning': {'requestId': 'ed1a42aa-750d-437b-95ec-a5249ab6da3c', 'installationId': '7f3eb4fa-f246-4b4b-8c50-0edcd0151638', 'sessionId': '61b345d2-7773-4118-81ee-21943b4ec77f', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.9', 'samcliVersion': '1.22.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': 'us-east-1', 'warningName': 'CodeDeployConditionWarning', 'warningCount': 0}}]}
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,500 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,500 | Using config file: samconfig.toml, config environment: default
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,500 | Expand command line arguments to:
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:15,500 | --template_file=/Users/avalle/development/bitbucket/policymap/infrastructure/lambda/create-route53-cname/template.yml --s3_bucket=policymap-lambdas20210512022937079100000002 --s3_prefix=CreateRoute53CNAME --output_template_file=/tmp/create-route53-cname.yml
null_resource.upload_create_r53_lambda (local-exec): Uploading to CreateRoute53CNAME/2aa112fb39ea7cd26a93885237213e0b 9088 / 9088 (100.00%)
null_resource.upload_create_r53_lambda (local-exec): Successfully packaged artifacts and wrote output template to file /tmp/create-route53-cname.yml.
null_resource.upload_create_r53_lambda (local-exec): Execute the following command to deploy the packaged template
null_resource.upload_create_r53_lambda (local-exec): sam deploy --template-file /tmp/create-route53-cname.yml --stack-name <YOUR STACK NAME>
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:16,481 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '44f29ed2-13b0-4235-8668-074f20743b64', 'installationId': '7f3eb4fa-f246-4b4b-8c50-0edcd0151638', 'sessionId': '61b345d2-7773-4118-81ee-21943b4ec77f', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.9', 'samcliVersion': '1.22.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': 'us-east-1', 'commandName': 'sam package', 'duration': 1953, 'exitReason': 'success', 'exitCode': 0}}]}
null_resource.upload_create_r53_lambda (local-exec): 2021-05-11 22:59:16,942 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
null_resource.upload_create_r53_lambda: Creation complete after 3s [id=6223747194174285962]
data.aws_s3_bucket_object.create_r53_cname_hash: Reading... [id=policymap-lambdas20210512022937079100000002/CreateRoute53CNAME/56341e34fd3536312881cd0f2aa2aa6a]
data.aws_s3_bucket_object.create_r53_cname_hash: Read complete after 1s [id=policymap-lambdas20210512022937079100000002/CreateRoute53CNAME/2aa112fb39ea7cd26a93885237213e0b]
╷
│ Warning: Applied changes may be incomplete
│
│ The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be fully updated. Run the following command to verify that
│ no other changes are pending:
│ terraform plan
│
│ Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part
│ of an error message.
╵
╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for aws_lambda_function.create_r53_cname to include new values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for .s3_key: was
│ cty.StringVal("CreateRoute53CNAME/56341e34fd3536312881cd0f2aa2aa6a"), but now cty.StringVal("CreateRoute53CNAME/2aa112fb39ea7cd26a93885237213e0b").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker. TF Version ❯ tf version
Terraform v0.15.1
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.37.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
Your version of Terraform is out of date! The latest version
is 0.15.3. You can update by downloading from https://www.terraform.io/downloads.html
|
Are there any updates regarding this issue? Still waiting for a fix. :-/ |
Still facing this in 2023 did anyone ever solve this? Thanks in advance |
Hi all 👋 I believe this may have been resolved with #31887 in version 5.32.0 of the provider. It may be worth testing with that version to see if you're still experiencing this behavior. |
Since we haven't heard back, I'm going to close this issue. If you're still having trouble, please feel free to open a new issue, referencing this one for context as needed. |
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. |
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. |
Terraform CLI and Terraform AWS Provider Version
"version": 4,
"terraform_version": "0.13.4"
Affected Resource(s)
aws_lambda_function - could not create the lambda function in the aws environment
Panic Output
Error: Provider produced inconsistent final plan
When expanding the plan for
module.create-lambda.aws_lambda_function.make_lambda to include
new values learned so far during apply, provider "registry.terraform.io/-/aws"
produced an invalid new value for .source_code_hash: was
cty.StringVal("FycrDOHF/Hd+E6e0Es3ZsuWiGPLSQdDFVw++adaBhJg="), but now
cty.StringVal("huJ5Mt3CVH7A6FlGSxMotgn0Q/tygsWTJkzIBiI1rPY=").
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ Terraform Apply ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲ ▲
Failed To Run Terraform Apply!
Expected Behavior
Expecting to create the aws lambda function.
Actual Behavior
It is not creating the lambda function since the hash of terraform plan and terraform apply is different.
Steps to Reproduce
create the terraform.tfvars, variables.tf and lambda.tf
terraform.tfvars
lambda_function_name = "test-lambda"
lambda_handler_name = "lambda_function.lambda_handler"
lambda_runtime = "python3.8"
lambda_timeout = "360"
lambda_package_name = "../../../../../dir-path/function.zip"
lambda_role_arn = "arn:aws:iam::xxxxxxxxx:role/path/lambda_role"
variables.tf
variable "lambda_function_name" {
type = string
}
variable "lambda_handler_name" {
type = string
}
variable "lambda_runtime" {
type = string
}
variable "lambda_timeout" {
type = string
}
variable "lambda_package_name" {
type = string
}
variable "lambda_role_arn" {
type = string
}
lambda.tf
module "create-lambda" {
source = "../../../../../athena-dir/modules/"
lambda_function_name = "${var.lambda_function_name}"
lambda_handler_name = "${var.lambda_handler_name}"
lambda_runtime = "${var.lambda_runtime}"
lambda_timeout = "${var.lambda_timeout}"
lambda_package_name = "${var.lambda_package_name}"
lambda_role_arn = "${var.lambda_role_arn}"
}
lambda.tf
resource "aws_lambda_function" "make_lambda" {
function_name = var.lambda_function_name
handler = var.lambda_handler_name
runtime = var.lambda_runtime
timeout = var.lambda_timeout
filename = var.lambda_package_name
source_code_hash = "${filebase64sha256(var.lambda_package_name)}"
role = var.lambda_role_arn
}
then, run terraform plan and apply.
The text was updated successfully, but these errors were encountered: