-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39413 from hashicorp/b-lb-listener-import-arti
elbv2/listener,target_group: Fix import differences, zero-values for absent values
- Loading branch information
Showing
10 changed files
with
633 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```release-note:bug | ||
resource/aws_lb_listener_rule: Fix several of the arguments to avoiding setting zero-values in situations where they shouldn't causing warnings and import differences | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_lb_target_group: Fix several of the arguments to avoiding setting zero-values in situations where they shouldn't causing warnings and import differences | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_lb_listener: Fix several of the arguments to avoiding setting zero-values in situations where they shouldn't causing warnings and import differences | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_lb_listener: Remove the limitation preventing setting both default_action.0.target_group_arn and default_action.0.forward to align with the AWS API which allows you to specify both a target group list and a top-level target group ARN if the ARNs match | ||
``` | ||
|
||
```release-note:note | ||
resource/aws_lb_listener: When importing a listener that has either a default action top-level target group ARN or a default action defining a forward action defining a target group with an ARN, include both in the configuration to avoid import differences | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_alb_listener: Fix several of the arguments to avoiding setting zero-values in situations where they shouldn't causing warnings and import differences | ||
``` | ||
|
||
```release-note:bug | ||
resource/aws_alb_listener: Remove the limitation preventing setting both default_action.0.target_group_arn and default_action.0.forward to align with the AWS API which allows you to specify both a target group list and a top-level target group ARN if the ARNs match | ||
``` | ||
|
||
```release-note:note | ||
resource/aws_alb_listener: When importing a listener that has either a default action top-level target group ARN or a default action defining a forward action defining a target group with an ARN, include both in the configuration to avoid import differences | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package acctest | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/terraform" | ||
) | ||
|
||
// ComposeAggregateImportStateCheckFunc lets you compose multiple ImportStateCheckFunc into | ||
// a single ImportStateCheckFunc. | ||
func ComposeAggregateImportStateCheckFunc(fs ...resource.ImportStateCheckFunc) resource.ImportStateCheckFunc { | ||
return func(is []*terraform.InstanceState) error { | ||
var result []error | ||
|
||
for i, f := range fs { | ||
if err := f(is); err != nil { | ||
result = append(result, fmt.Errorf("Import check %d/%d error: %w", i+1, len(fs), err)) | ||
} | ||
} | ||
|
||
return errors.Join(result...) | ||
} | ||
} | ||
|
||
func ImportCheckResourceAttr(key, expected string) resource.ImportStateCheckFunc { | ||
return func(is []*terraform.InstanceState) error { | ||
if len(is) != 1 { | ||
return fmt.Errorf("Attribute '%s' expected 1 instance state, got %d", key, len(is)) | ||
} | ||
|
||
rs := is[0] | ||
if rs.Attributes[key] != expected { | ||
return fmt.Errorf("Attribute '%s' expected %s, got %s", key, expected, rs.Attributes[key]) | ||
} | ||
return nil | ||
} | ||
} | ||
|
||
func ImportCheckResourceAttrSet(key string, set bool) resource.ImportStateCheckFunc { | ||
return func(is []*terraform.InstanceState) error { | ||
if len(is) != 1 { | ||
return fmt.Errorf("Attribute '%s' expected 1 instance state, got %d", key, len(is)) | ||
} | ||
|
||
rs := is[0] | ||
if set && rs.Attributes[key] == "" { | ||
return fmt.Errorf("Attribute '%s' expected to be set, got not set", key) | ||
} | ||
|
||
if !set && rs.Attributes[key] != "" { | ||
return fmt.Errorf("Attribute '%s' expected to be not set, got set (%s)", key, rs.Attributes[key]) | ||
} | ||
|
||
return nil | ||
} | ||
} |
Oops, something went wrong.