-
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
[Bug]: Importing aws_lb_listener
and aws_lb_target_group
incorrectly sets defaults for absent optional values
#38861
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
aws_lb_listener
incorrectly sets defaults for absent optional values aws_lb_listener
and aws_lb_target_group
incorrectly sets defaults for absent optional values
A similar thing happens for The wrong values aren't surfaced to users though because they only get inserted into the state. Those attributes are ignored when computing the diff and when applying it . Here pointers are converted to their primitives, which yields terraform-provider-aws/internal/service/elbv2/target_group.go Lines 1170 to 1176 in 3724def
|
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. |
This functionality has been released in v5.69.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! |
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 Core Version
1.5.7
AWS Provider Version
5.62.0
Affected Resource(s)
aws_lb_listener, aws_alb_listener, aws_lb_target_group, aws_alb_target_group
Expected Behavior
When importing a Listener, optional attributes like
default_action.forward.stickiness.duration
are getting set to the types default value (e.g. 0 for number or""
for string).Actual Behavior
Those attributes shouldn't be set at all when their corresponding field in the SDK response is not set because the default values are not valid for most of the attributes.
E.g.
0
is not valid for duration (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#duration)0
is not valid for order (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#order)This is happening because fields of the API response are casted to primitive types before first checking whether they're non-nil. E.g.
terraform-provider-aws/internal/service/elbv2/listener.go
Lines 1170 to 1171 in 3724def
A similar bug existed for create/update and was fixed here: https://github.com/hashicorp/terraform-provider-aws/pull/35671/files#diff-eeba380b8533b2e177f0bab8c04a32da3d34c417a7655baef7b4aabdeb244564R933-R938
Running
terraform apply
after the import corrects the attributes that were wrongly set to state.Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
Run
terraform apply
, then uncomment the resource at the bottom and run import with the output of the listener ARN.E.g:
Now run
terraform apply
again and you'll see the that attributes like stickiness duration have been wrongly set in the state and show a diff:Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: