Open mgkeen opened 5 years ago
Further update: When my automated deployment tests ran i got the following:
aws_lambda_function.lambda: diffs didn't match during apply. This is a bug with Terraform and should be reported as a GitHub Issue.
Please include the following information in your report:
Terraform Version: 0.11.13
Resource ID: aws_lambda_function.lambda
Mismatch reason: extra attributes: vpc_config.0.security_group_ids.2170271681, vpc_config.0.subnet_ids.767090540, vpc_config.#, vpc_config.0.security_group_ids.3652956519, vpc_config.0.subnet_ids.2445766162, vpc_config.0.security_group_ids.#, vpc_config.0.subnet_ids.#
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"source_code_hash":*terraform.ResourceAttrDiff{Old:"dZvTurqfbWE7fcdQtZ+5zjrKMElkqvoVspXJFtkO64M=", New:"HverdkOpN6cy7ynwrxZfJ/RPM6fF6RKPkv/G9LHaq0M=", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "last_modified":*terraform.ResourceAttrDiff{Old:"2019-05-01T23:59:08.790+0000", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"vpc_config.0.security_group_ids.3652956519":*terraform.ResourceAttrDiff{Old:"", New:"sg-0231dfb3bc6fc7cab", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.0.security_group_ids.2170271681":*terraform.ResourceAttrDiff{Old:"", New:"sg-0abca9f0c69752ed4", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "last_modified":*terraform.ResourceAttrDiff{Old:"2019-05-01T23:59:08.790+0000", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.#":*terraform.ResourceAttrDiff{Old:"0", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.0.subnet_ids.2445766162":*terraform.ResourceAttrDiff{Old:"", New:"subnet-0b37b93685387cce1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "source_code_hash":*terraform.ResourceAttrDiff{Old:"dZvTurqfbWE7fcdQtZ+5zjrKMElkqvoVspXJFtkO64M=", New:"HverdkOpN6cy7ynwrxZfJ/RPM6fF6RKPkv/G9LHaq0M=", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.0.security_group_ids.#":*terraform.ResourceAttrDiff{Old:"0", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.0.subnet_ids.#":*terraform.ResourceAttrDiff{Old:"0", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "vpc_config.0.subnet_ids.767090540":*terraform.ResourceAttrDiff{Old:"", New:"subnet-0efd57b2b04f1570d", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)}
On a second run it completed successfully
I'm having this problem too. Any solution available?
Try adding ignore_source_code_hash = true
to your resource "aws_lambda_function" "lambda"
I am also facing this issue. Any solutions yet?
Is there any update on this?
We are facing the same issue where terraform apply
fails the 1st run after adding vpc_config to existing lambda with below error:
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for
│ module.x.aws_lambda_function.x
│ to include new values learned so far during apply, provider
│ "registry.terraform.io/hashicorp/aws" produced an invalid new value for
│ .vpc_config: block count changed from 0 to 1.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.╵
Re-running terraform apply
works fine.
Expectation is for this to work on the 1st run of terraform apply
too.
Same as above, the 2nd time I ran apply
it worked fine. I had to find this bug report 1st to figure that one out... Maybe it would be worth adding some note in the docs for vpc_config
?
I have an existing lambda function that I am trying to move into a VPC. The lambda is created via a module (configuration for the module listed below). Adding the vpc_config section and passing lists of subnet ids and security groups doesn't appear to alter the lambda function at all. If i alter a variable that forces a new resource (e.g. function name), then the change is picked up.
UPDATE: This bug only appears at the same time as creating the VPC resources. Creating the VPC resources first, and then running
terraform apply
a second time gives the expected behaviour.Community Note
Terraform Version
terraform:
0.11.13
provider.aws:2.8.0
Affected Resource(s)
aws_lambda_function
Terraform Configuration Files
Expected Behavior
Should update the vpc_config on the existing lambda function:
Actual Behavior
No changes applied when just adding vpc_config. If something that forces a new resource is changed (e.g. function name), then it applies the vpc_config changes.
Steps to Reproduce
terraform apply
terraform apply
References
https://github.com/terraform-providers/terraform-provider-aws/issues/1073 I saw this issue, but not sure if it is related or not