Skip to content

Commit

Permalink
r/aws_lb: Only flatten 'connection_logs' for ALBs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Dec 12, 2023
1 parent b7c9696 commit dc7fbe2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/service/elbv2/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta
d.Set("enforce_security_group_inbound_rules_on_private_link_traffic", lb.EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic)
d.Set("internal", aws.StringValue(lb.Scheme) == elbv2.LoadBalancerSchemeEnumInternal)
d.Set("ip_address_type", lb.IpAddressType)
d.Set("load_balancer_type", lb.Type)
lbType := aws.StringValue(lb.Type)
d.Set("load_balancer_type", lbType)
d.Set("name", lb.LoadBalancerName)
d.Set("name_prefix", create.NamePrefixFromName(aws.StringValue(lb.LoadBalancerName)))
d.Set("security_groups", aws.StringValueSlice(lb.SecurityGroups))
Expand All @@ -522,8 +523,10 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta
return sdkdiag.AppendErrorf(diags, "setting access_logs: %s", err)
}

if err := d.Set("connection_logs", []interface{}{flattenLoadBalancerConnectionLogsAttributes(attributes)}); err != nil {
return sdkdiag.AppendErrorf(diags, "setting connection_logs: %s", err)
if lbType == elbv2.LoadBalancerTypeEnumApplication {
if err := d.Set("connection_logs", []interface{}{flattenLoadBalancerConnectionLogsAttributes(attributes)}); err != nil {
return sdkdiag.AppendErrorf(diags, "setting connection_logs: %s", err)
}
}

loadBalancerAttributes.flatten(d, attributes)
Expand Down
2 changes: 1 addition & 1 deletion internal/service/elbv2/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestAccELBV2LoadBalancer_NLB_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "access_logs.#", "1"),
resource.TestCheckResourceAttr(resourceName, "access_logs.0.enabled", "false"),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "elasticloadbalancing", regexache.MustCompile(fmt.Sprintf("loadbalancer/net/%s/.+", rName))),
resource.TestCheckResourceAttr(resourceName, "connection_logs.#", "0"),
resource.TestCheckNoResourceAttr(resourceName, "connection_logs.#"),
resource.TestCheckResourceAttrSet(resourceName, "dns_name"),
resource.TestCheckResourceAttr(resourceName, "dns_record_client_routing_policy", "any_availability_zone"),
resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"),
Expand Down

0 comments on commit dc7fbe2

Please sign in to comment.