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

Elb awssdkv2 migration #38212

Merged
merged 39 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f76d564
elb: Migrate to AWS SDK v2
mattburgess Jun 26, 2024
50d9574
make gen
mattburgess Jul 1, 2024
eade42a
r/app_cookie_stickiness_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
30cb973
r/elb_attachment: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
6607aff
r/load_balancer_backend_server_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
f599819
r/lb_cookie_stickiness_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
3996f19
r/lb_ssl_negotiation_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
ed3ea69
r/load_balancer_listener_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
def43f9
d/elb, r/elb: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
36c241d
r/load_balancer_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
1aba7d7
r/proxy_protocol_policy: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
2821d86
d/elb_service_account: Migrate to AWS SDK v2
mattburgess Jul 1, 2024
dc55eb3
elb: Last AWS SDK v2 migration bits
mattburgess Jul 1, 2024
79ba7ba
r/autoscaling_group: Migrate to AWS SDK v2 (elb)
mattburgess Jul 1, 2024
1fb950e
Merge branch 'main' into HEAD
ewbankkit Jul 9, 2024
77579f2
elb: Tidy up 'flex'.
ewbankkit Jul 9, 2024
81796ca
r/aws_app_cookie_stickiness_policy: Reduce visibility.
ewbankkit Jul 9, 2024
2c5b6cf
r/aws_elb_attachment: Reduce visibility.
ewbankkit Jul 9, 2024
7553741
r/aws_load_balancer_backend_server_policy: Reduce visibility.
ewbankkit Jul 9, 2024
809ff6e
Remove some constants.
ewbankkit Jul 9, 2024
7d63c34
d/aws_elb_hosted_zone_id: Reduce visibility.
ewbankkit Jul 9, 2024
c4fcd66
r/aws_lb_cookie_stickiness_policy: Reduce visibility.
ewbankkit Jul 9, 2024
f0aaa63
r/aws_lb_ssl_negotiation_policy: Reduce visibility.
ewbankkit Jul 9, 2024
8710875
r/aws_load_balancer_listener_policy: Reduce visibility.
ewbankkit Jul 9, 2024
a0a1464
r/aws_load_balancer_policy: Reduce visibility.
ewbankkit Jul 9, 2024
d20b149
d/aws_elb_service_account: Reduce visibility.
ewbankkit Jul 9, 2024
542881f
r/aws_proxy_protocol_policy: Reduce visibility.
ewbankkit Jul 9, 2024
0700f9e
d/aws_elb: Reduce visibility.
ewbankkit Jul 9, 2024
feeb2b8
elb: Fix sweeper compilation errors.
ewbankkit Jul 9, 2024
a6b0dd2
Fix golangci-lint 'unparam'.
ewbankkit Jul 9, 2024
6de4be1
Fix golangci-lint 'gosimple'.
ewbankkit Jul 9, 2024
1d4b2cc
'aws_elasticloadbalancing' -> 'aws_elb' in acceptance tests.
ewbankkit Jul 10, 2024
338a499
Correct load balancer attribute name.
ewbankkit Jul 10, 2024
2a58c26
'aws_awstypes' -> 'aws_elb' in acceptance tests.
ewbankkit Jul 10, 2024
9510d93
elb: Handle 'LoadBalancerNotFound: There is no ACTIVE Load Balancer n…
ewbankkit Jul 10, 2024
ffb9cb0
r/aws_iam_server_certificate: Add configurable delete timeout.
ewbankkit Jul 10, 2024
62870ba
elb: Increase aws_iam_server_certificate delete timeout in acceptance…
ewbankkit Jul 10, 2024
b8a244f
Merge branch 'main' into HEAD
ewbankkit Jul 10, 2024
52b6e6f
Run 'make clean-tidy'.
ewbankkit Jul 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/38212.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_iam_server_certificate: Add configurable `delete` timeout
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/eks v1.46.0
github.com/aws/aws-sdk-go-v2/service/elasticache v1.40.1
github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.26.0
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.26.1
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.33.1
github.com/aws/aws-sdk-go-v2/service/emr v1.42.0
github.com/aws/aws-sdk-go-v2/service/emrserverless v1.23.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ github.com/aws/aws-sdk-go-v2/service/elasticache v1.40.1 h1:yJMmaQ3jTpCrsXl0lxQU
github.com/aws/aws-sdk-go-v2/service/elasticache v1.40.1/go.mod h1:HfavnpYheVa3TXRxHNZYIM/BMI8hmSbtiSbYxqdri/4=
github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.26.0 h1:HKN6OvyM2N4mCME+1MgkBemV1Mle3VSuag4Q5+jaPM0=
github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.26.0/go.mod h1:H8YbT18eu4O03RiBqdDderRdpnHe2Pv439zdO5mmbfU=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.26.1 h1:/x4d5NeeoKJAhyZ5zHnBOaxOSotobVb9mXeprdl363I=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.26.1/go.mod h1:Dm9KFhagyV3Ecne6tpYIXWh51N/Q288vpm+0u3P/gbo=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.33.1 h1:XuwjSEGfLxo6UJtpJVy/E80GpE1gNclDBv5k1nTQcCs=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.33.1/go.mod h1:74D8OQ00uEvvpuG5e4VX+/2v3MC2pltRtzNyXJnEjrI=
github.com/aws/aws-sdk-go-v2/service/emr v1.42.0 h1:n3e3/X7ixZrQja0ot3l6M19nw8EarUo1yR0rH4e8aec=
Expand Down
6 changes: 3 additions & 3 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions internal/flex/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,16 @@ func IntValueToString(v int) *string {
return aws.String(strconv.Itoa(v))
}

// Int64ToStringValue converts an int64 pointer to a Go string value.
// Int32ToStringValue converts an int32 pointer to a Go string value.
func Int32ToStringValue(v *int32) string {
return strconv.FormatInt(int64(aws.Int32Value(v)), 10)
}

// Int32ValueToStringValue converts an int32 value to a Go string value.
func Int32ValueToStringValue(v int32) string {
return strconv.FormatInt(int64(v), 10)
}

// Int64ToStringValue converts an int64 pointer to a Go string value.
func Int64ToStringValue(v *int64) string {
return strconv.FormatInt(aws.Int64Value(v), 10)
Expand All @@ -450,15 +455,27 @@ func StringToIntValue(v *string) int {
// StringToInt32Value converts a string pointer to a Go int32 value.
// Invalid integer strings are converted to 0.
func StringToInt32Value(v *string) int32 {
i, _ := strconv.ParseInt(aws.StringValue(v), 0, 32)
return int32(i)
return StringValueToInt32Value(aws.StringValue(v))
}

// StringValueToBase64String converts a string to a Go base64 string pointer.
func StringValueToBase64String(v string) *string {
return aws.String(itypes.Base64EncodeOnce([]byte(v)))
}

// StringValueToInt64 converts a string to a Go int32 pointer.
// Invalid integer strings are converted to 0.
func StringValueToInt32(v string) *int32 {
return aws.Int32(StringValueToInt32Value(v))
}

// StringValueToInt32Value converts a string to a Go int32 value.
// Invalid integer strings are converted to 0.
func StringValueToInt32Value(v string) int32 {
i, _ := strconv.ParseInt(v, 0, 32)
return int32(i)
}

// StringValueToInt64 converts a string to a Go int64 pointer.
// Invalid integer strings are converted to 0.
func StringValueToInt64(v string) *int64 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func listOfMap(tags tftags.KeyValueTags) []any {

{{- if .TagKeyType }}
// TagKeys returns {{ .ServicePackage }} service tag keys.
func TagKeys(tags tftags.KeyValueTags) []*{{ .AWSService }}.{{ .TagKeyType }} {
result := make([]*{{ .AWSService }}.{{ .TagKeyType }}, 0, len(tags))
func TagKeys(tags tftags.KeyValueTags) []awstypes.{{ .TagKeyType }} {
result := make([]awstypes.{{ .TagKeyType }}, 0, len(tags))

for k := range tags.Map() {
tagKey := &{{ .AWSService }}.{{ .TagKeyType }}{
tagKey := awstypes.{{ .TagKeyType }}{
{{ .TagTypeKeyElem }}: aws.String(k),
}

Expand Down
4 changes: 4 additions & 0 deletions internal/service/autoscaling/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ func (lifecycleHookLifecycleTransition) Values() []lifecycleHookLifecycleTransit
lifecycleHookLifecycleTransitionInstanceTerminating,
}
}

const (
elbInstanceStateInService = "InService"
)
19 changes: 9 additions & 10 deletions internal/service/autoscaling/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
awstypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/hashicorp/aws-sdk-go-base/v2/tfawserr"
"github.com/hashicorp/go-cty/cty"
Expand All @@ -33,7 +33,6 @@ import ( // nosemgrep:ci.semgrep.aws.multiple-service-imports
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
"github.com/hashicorp/terraform-provider-aws/internal/flex"
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2/types/nullable"
tfelb "github.com/hashicorp/terraform-provider-aws/internal/service/elb"
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
Expand Down Expand Up @@ -1211,7 +1210,7 @@ func resourceGroupCreate(ctx context.Context, d *schema.ResourceData, meta inter
return nil
}

if err := waitGroupCapacitySatisfied(ctx, conn, meta.(*conns.AWSClient).ELBConn(ctx), meta.(*conns.AWSClient).ELBV2Conn(ctx), d.Id(), f, startTime, d.Get("ignore_failed_scaling_activities").(bool), timeout); err != nil {
if err := waitGroupCapacitySatisfied(ctx, conn, meta.(*conns.AWSClient).ELBClient(ctx), meta.(*conns.AWSClient).ELBV2Conn(ctx), d.Id(), f, startTime, d.Get("ignore_failed_scaling_activities").(bool), timeout); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for Auto Scaling Group (%s) capacity satisfied: %s", d.Id(), err)
}
}
Expand Down Expand Up @@ -1708,7 +1707,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter
return nil
}

if err := waitGroupCapacitySatisfied(ctx, conn, meta.(*conns.AWSClient).ELBConn(ctx), meta.(*conns.AWSClient).ELBV2Conn(ctx), d.Id(), f, startTime, d.Get("ignore_failed_scaling_activities").(bool), timeout); err != nil {
if err := waitGroupCapacitySatisfied(ctx, conn, meta.(*conns.AWSClient).ELBClient(ctx), meta.(*conns.AWSClient).ELBV2Conn(ctx), d.Id(), f, startTime, d.Get("ignore_failed_scaling_activities").(bool), timeout); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for Auto Scaling Group (%s) capacity satisfied: %s", d.Id(), err)
}
}
Expand Down Expand Up @@ -1965,16 +1964,16 @@ func drainWarmPool(ctx context.Context, conn *autoscaling.Client, name string, t
return nil
}

func findELBInstanceStates(ctx context.Context, conn *elb.ELB, g *awstypes.AutoScalingGroup) (map[string]map[string]string, error) {
func findELBInstanceStates(ctx context.Context, conn *elasticloadbalancing.Client, g *awstypes.AutoScalingGroup) (map[string]map[string]string, error) {
instanceStates := make(map[string]map[string]string)

for _, v := range g.LoadBalancerNames {
lbName := v
input := &elb.DescribeInstanceHealthInput{
input := &elasticloadbalancing.DescribeInstanceHealthInput{
LoadBalancerName: aws.String(lbName),
}

output, err := conn.DescribeInstanceHealthWithContext(ctx, input)
output, err := conn.DescribeInstanceHealth(ctx, input)

if err != nil {
return nil, fmt.Errorf("reading load balancer (%s) instance health: %w", lbName, err)
Expand Down Expand Up @@ -2284,7 +2283,7 @@ func findWarmPoolByName(ctx context.Context, conn *autoscaling.Client, name stri
return findWarmPool(ctx, conn, input)
}

func statusGroupCapacity(ctx context.Context, conn *autoscaling.Client, elbconn *elb.ELB, elbv2conn *elbv2.ELBV2, name string, cb func(int, int) error, startTime time.Time, ignoreFailedScalingActivities bool) retry.StateRefreshFunc {
func statusGroupCapacity(ctx context.Context, conn *autoscaling.Client, elbconn *elasticloadbalancing.Client, elbv2conn *elbv2.ELBV2, name string, cb func(int, int) error, startTime time.Time, ignoreFailedScalingActivities bool) retry.StateRefreshFunc {
return func() (interface{}, string, error) {
if !ignoreFailedScalingActivities {
// Check for fatal error in activity logs.
Expand Down Expand Up @@ -2359,7 +2358,7 @@ func statusGroupCapacity(ctx context.Context, conn *autoscaling.Client, elbconn
inAll := true

for _, v := range lbInstanceStates {
if state, ok := v[instanceID]; ok && state != tfelb.InstanceStateInService {
if state, ok := v[instanceID]; ok && state != elbInstanceStateInService {
inAll = false
break
}
Expand Down Expand Up @@ -2539,7 +2538,7 @@ func statusWarmPoolInstanceCount(ctx context.Context, conn *autoscaling.Client,
}
}

func waitGroupCapacitySatisfied(ctx context.Context, conn *autoscaling.Client, elbconn *elb.ELB, elbv2conn *elbv2.ELBV2, name string, cb func(int, int) error, startTime time.Time, ignoreFailedScalingActivities bool, timeout time.Duration) error {
func waitGroupCapacitySatisfied(ctx context.Context, conn *autoscaling.Client, elbconn *elasticloadbalancing.Client, elbv2conn *elbv2.ELBV2, name string, cb func(int, int) error, startTime time.Time, ignoreFailedScalingActivities bool, timeout time.Duration) error {
stateConf := &retry.StateChangeConf{
Target: []string{"ok"},
Refresh: statusGroupCapacity(ctx, conn, elbconn, elbv2conn, name, cb, startTime, ignoreFailedScalingActivities),
Expand Down
Loading
Loading