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

r/aws_elbv2_listener: fix crash reading forward action #39039

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Aug 26, 2024

Description

Adds a check to the flattenLbForwardAction function to verify the default actions attribute is known and not null before checking the length. Previously the length was checked without verifying the attribute was known, potentially resulting in a crash during read operations.

Relations

Closes #39031

Output from Acceptance Testing

% make testacc PKG=elbv2 TESTS=TestAccELBV2Listener_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.6 test ./internal/service/elbv2/... -v -count 1 -parallel 20 -run='TestAccELBV2Listener_'  -timeout 360m

--- PASS: TestAccELBV2Listener_mutualAuthenticationPassthrough (227.28s)
=== CONT  TestAccELBV2Listener_ActionForward_ForwardBlock_AddStickiness
--- PASS: TestAccELBV2Listener_mutualAuthentication (229.83s)
=== CONT  TestAccELBV2Listener_forwardTargetARNAndBlock
--- PASS: TestAccELBV2Listener_oidc (241.32s)
=== CONT  TestAccELBV2Listener_forwardWeighted
--- PASS: TestAccELBV2Listener_ActionForward_TargetGroupARNToForwardBlock_WeightAndStickiness (244.97s)
=== CONT  TestAccELBV2Listener_updateForwardBasic
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlockToTargetGroupARN_NoChanges (246.47s)
=== CONT  TestAccELBV2Listener_disappears
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nullOverlappingResourceTag (249.45s)
=== CONT  TestAccELBV2Listener_Gateway_basic
--- PASS: TestAccELBV2Listener_tags_DefaultTags_emptyProviderOnlyTag (252.40s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Add
--- PASS: TestAccELBV2Listener_DefaultAction_specifyOrder (253.34s)
=== CONT  TestAccELBV2Listener_Application_basic
--- PASS: TestAccELBV2Listener_Protocol_upd (255.67s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Replace
--- PASS: TestAccELBV2Listener_backwardsCompatibility (256.87s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnCreate
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlockToTargetGroupARN_WeightAndStickiness (258.95s)
=== CONT  TestAccELBV2Listener_DefaultAction_defaultOrder
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_RemoveStickiness (262.88s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_nullNonOverlappingResourceTag
--- PASS: TestAccELBV2Listener_DefaultAction_actionDisappears (266.71s)
=== CONT  TestAccELBV2Listener_ActionForward_IgnoreFields
--- PASS: TestAccELBV2Listener_ActionForward_TargetGroupARNToForwardBlock_NoChanges (270.91s)
=== CONT  TestAccELBV2Listener_redirect
--- PASS: TestAccELBV2Listener_Network_basic (272.20s)
=== CONT  TestAccELBV2Listener_cognito
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_RemoveAction (274.75s)
=== CONT  TestAccELBV2Listener_fixedResponse
--- PASS: TestAccELBV2Listener_tags (275.54s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_providerOnly
--- PASS: TestAccELBV2Listener_Protocol_https (280.82s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_emptyResourceTag
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_AddAction (297.53s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_updateToResourceOnly
--- PASS: TestAccELBV2Listener_redirectWithTargetGroupARN (325.95s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_updateToProviderOnly
--- PASS: TestAccELBV2Listener_forwardTargetARNAndBlock (192.93s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_overlapping
--- PASS: TestAccELBV2Listener_Gateway_basic (189.50s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_nonOverlapping
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_AddStickiness (222.54s)
=== CONT  TestAccELBV2Listener_Protocol_tls
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnCreate (201.74s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnCreate
--- PASS: TestAccELBV2Listener_Application_basic (207.93s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Replace
--- PASS: TestAccELBV2Listener_updateForwardBasic (220.31s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Add
--- PASS: TestAccELBV2Listener_disappears (224.12s)
=== CONT  TestAccELBV2Listener_tags_AddOnUpdate
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nullNonOverlappingResourceTag (210.19s)
=== CONT  TestAccELBV2Listener_tags_null
--- PASS: TestAccELBV2Listener_DefaultAction_defaultOrder (217.43s)
=== CONT  TestAccELBV2Listener_LoadBalancerARN_gatewayLoadBalancer
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Add (230.66s)
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/authenticate-cognito
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Replace (228.55s)
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/authenticate-oidc
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/forward
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/fixed-response
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/redirect
--- PASS: TestAccELBV2Listener_EmptyDefaultAction (0.00s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/authenticate-cognito (1.63s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/authenticate-oidc (1.87s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/forward (1.70s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/fixed-response (1.68s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/redirect (1.61s)
--- PASS: TestAccELBV2Listener_ActionForward_IgnoreFields (221.61s)
--- PASS: TestAccELBV2Listener_redirect (221.82s)
--- PASS: TestAccELBV2Listener_fixedResponse (218.53s)
--- PASS: TestAccELBV2Listener_cognito (227.62s)
--- PASS: TestAccELBV2Listener_forwardWeighted (259.11s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_emptyResourceTag (221.82s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_updateToResourceOnly (257.67s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_updateToProviderOnly (255.03s)
--- PASS: TestAccELBV2Listener_LoadBalancerARN_gatewayLoadBalancer (155.57s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_providerOnly (367.38s)
--- PASS: TestAccELBV2Listener_tags_null (204.67s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Replace (220.60s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnCreate (233.93s)
--- PASS: TestAccELBV2Listener_tags_AddOnUpdate (224.94s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Add (240.76s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_overlapping (307.22s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nonOverlapping (310.24s)
--- PASS: TestAccELBV2Listener_Protocol_tls (426.18s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/elbv2      884.767s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added service/elbv2 Issues and PRs that pertain to the elbv2 service. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Aug 26, 2024
Adds a check to the `flattenLbForwardAction` function to verify the default actions attribute is known and not null before checking the length. Previously the length was checked without verifying the attribute was known, potentially resulting in a crash during read operations.

```console
% make testacc PKG=elbv2 TESTS=TestAccELBV2Listener_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.6 test ./internal/service/elbv2/... -v -count 1 -parallel 20 -run='TestAccELBV2Listener_'  -timeout 360m

--- PASS: TestAccELBV2Listener_mutualAuthenticationPassthrough (227.28s)
=== CONT  TestAccELBV2Listener_ActionForward_ForwardBlock_AddStickiness
--- PASS: TestAccELBV2Listener_mutualAuthentication (229.83s)
=== CONT  TestAccELBV2Listener_forwardTargetARNAndBlock
--- PASS: TestAccELBV2Listener_oidc (241.32s)
=== CONT  TestAccELBV2Listener_forwardWeighted
--- PASS: TestAccELBV2Listener_ActionForward_TargetGroupARNToForwardBlock_WeightAndStickiness (244.97s)
=== CONT  TestAccELBV2Listener_updateForwardBasic
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlockToTargetGroupARN_NoChanges (246.47s)
=== CONT  TestAccELBV2Listener_disappears
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nullOverlappingResourceTag (249.45s)
=== CONT  TestAccELBV2Listener_Gateway_basic
--- PASS: TestAccELBV2Listener_tags_DefaultTags_emptyProviderOnlyTag (252.40s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Add
--- PASS: TestAccELBV2Listener_DefaultAction_specifyOrder (253.34s)
=== CONT  TestAccELBV2Listener_Application_basic
--- PASS: TestAccELBV2Listener_Protocol_upd (255.67s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Replace
--- PASS: TestAccELBV2Listener_backwardsCompatibility (256.87s)
=== CONT  TestAccELBV2Listener_tags_ComputedTag_OnCreate
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlockToTargetGroupARN_WeightAndStickiness (258.95s)
=== CONT  TestAccELBV2Listener_DefaultAction_defaultOrder
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_RemoveStickiness (262.88s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_nullNonOverlappingResourceTag
--- PASS: TestAccELBV2Listener_DefaultAction_actionDisappears (266.71s)
=== CONT  TestAccELBV2Listener_ActionForward_IgnoreFields
--- PASS: TestAccELBV2Listener_ActionForward_TargetGroupARNToForwardBlock_NoChanges (270.91s)
=== CONT  TestAccELBV2Listener_redirect
--- PASS: TestAccELBV2Listener_Network_basic (272.20s)
=== CONT  TestAccELBV2Listener_cognito
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_RemoveAction (274.75s)
=== CONT  TestAccELBV2Listener_fixedResponse
--- PASS: TestAccELBV2Listener_tags (275.54s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_providerOnly
--- PASS: TestAccELBV2Listener_Protocol_https (280.82s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_emptyResourceTag
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_AddAction (297.53s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_updateToResourceOnly
--- PASS: TestAccELBV2Listener_redirectWithTargetGroupARN (325.95s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_updateToProviderOnly
--- PASS: TestAccELBV2Listener_forwardTargetARNAndBlock (192.93s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_overlapping
--- PASS: TestAccELBV2Listener_Gateway_basic (189.50s)
=== CONT  TestAccELBV2Listener_tags_DefaultTags_nonOverlapping
--- PASS: TestAccELBV2Listener_ActionForward_ForwardBlock_AddStickiness (222.54s)
=== CONT  TestAccELBV2Listener_Protocol_tls
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnCreate (201.74s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnCreate
--- PASS: TestAccELBV2Listener_Application_basic (207.93s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Replace
--- PASS: TestAccELBV2Listener_updateForwardBasic (220.31s)
=== CONT  TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Add
--- PASS: TestAccELBV2Listener_disappears (224.12s)
=== CONT  TestAccELBV2Listener_tags_AddOnUpdate
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nullNonOverlappingResourceTag (210.19s)
=== CONT  TestAccELBV2Listener_tags_null
--- PASS: TestAccELBV2Listener_DefaultAction_defaultOrder (217.43s)
=== CONT  TestAccELBV2Listener_LoadBalancerARN_gatewayLoadBalancer
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Add (230.66s)
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/authenticate-cognito
--- PASS: TestAccELBV2Listener_tags_ComputedTag_OnUpdate_Replace (228.55s)
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/authenticate-oidc
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/forward
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/fixed-response
=== CONT  TestAccELBV2Listener_EmptyDefaultAction/redirect
--- PASS: TestAccELBV2Listener_EmptyDefaultAction (0.00s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/authenticate-cognito (1.63s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/authenticate-oidc (1.87s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/forward (1.70s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/fixed-response (1.68s)
    --- PASS: TestAccELBV2Listener_EmptyDefaultAction/redirect (1.61s)
--- PASS: TestAccELBV2Listener_ActionForward_IgnoreFields (221.61s)
--- PASS: TestAccELBV2Listener_redirect (221.82s)
--- PASS: TestAccELBV2Listener_fixedResponse (218.53s)
--- PASS: TestAccELBV2Listener_cognito (227.62s)
--- PASS: TestAccELBV2Listener_forwardWeighted (259.11s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_emptyResourceTag (221.82s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_updateToResourceOnly (257.67s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_updateToProviderOnly (255.03s)
--- PASS: TestAccELBV2Listener_LoadBalancerARN_gatewayLoadBalancer (155.57s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_providerOnly (367.38s)
--- PASS: TestAccELBV2Listener_tags_null (204.67s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Replace (220.60s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnCreate (233.93s)
--- PASS: TestAccELBV2Listener_tags_AddOnUpdate (224.94s)
--- PASS: TestAccELBV2Listener_tags_EmptyTag_OnUpdate_Add (240.76s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_overlapping (307.22s)
--- PASS: TestAccELBV2Listener_tags_DefaultTags_nonOverlapping (310.24s)
--- PASS: TestAccELBV2Listener_Protocol_tls (426.18s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/elbv2      884.767s
```
@jar-b jar-b added crash Results from or addresses a Terraform crash or kernel panic. bug Addresses a defect in current functionality. labels Aug 26, 2024
@jar-b jar-b marked this pull request as ready for review August 26, 2024 15:28
@jar-b jar-b requested a review from a team as a code owner August 26, 2024 15:28
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

@jar-b jar-b merged commit c600e33 into main Aug 26, 2024
50 checks passed
@jar-b jar-b deleted the b-lb-listener-rule-crash branch August 26, 2024 17:01
@github-actions github-actions bot added this to the v5.65.0 milestone Aug 26, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Aug 26, 2024
@samveen
Copy link

samveen commented Aug 27, 2024

@jar-b Thank you for the quick turnaround.

@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 29, 2024
Copy link

This functionality has been released in v5.65.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 pull request 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 related to this change, 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 Sep 29, 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. crash Results from or addresses a Terraform crash or kernel panic. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: panic: value is null on decoding ReadResource result for aws_lb_listener_rule in version v5.63.1
3 participants