Skip to content

Commit

Permalink
create target group not explicity specify ipAddressType ipv4
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorj committed Oct 20, 2021
1 parent 61d970b commit ea78369
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/deploy/elbv2/target_group_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func buildSDKCreateTargetGroupInput(tgSpec elbv2model.TargetGroupSpec) *elbv2sdk
sdkObj.TargetType = awssdk.String(string(tgSpec.TargetType))
sdkObj.Port = awssdk.Int64(tgSpec.Port)
sdkObj.Protocol = awssdk.String(string(tgSpec.Protocol))
if tgSpec.IPAddressType != nil {
if tgSpec.IPAddressType != nil && *tgSpec.IPAddressType != elbv2model.TargetGroupIPAddressTypeIPv4 {
sdkObj.IpAddressType = (*string)(tgSpec.IPAddressType)
}
if tgSpec.ProtocolVersion != nil {
Expand Down
49 changes: 45 additions & 4 deletions pkg/deploy/elbv2/target_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
port9090 := intstr.FromInt(9090)
protocolHTTP := elbv2model.ProtocolHTTP
protocolVersionHTTP2 := elbv2model.ProtocolVersionHTTP2
ipAddressTypeIPv4 := elbv2model.TargetGroupIPAddressTypeIPv4
ipAddressTypeIPv6 := elbv2model.TargetGroupIPAddressTypeIPv6
type args struct {
tgSpec elbv2model.TargetGroupSpec
}
Expand All @@ -398,10 +400,11 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
name: "standard case",
args: args{
tgSpec: elbv2model.TargetGroupSpec{
Name: "my-tg",
TargetType: elbv2model.TargetTypeIP,
Port: 8080,
Protocol: elbv2model.ProtocolHTTP,
Name: "my-tg",
TargetType: elbv2model.TargetTypeIP,
Port: 8080,
Protocol: elbv2model.ProtocolHTTP,
IPAddressType: &ipAddressTypeIPv4,
HealthCheckConfig: &elbv2model.TargetGroupHealthCheckConfig{
Port: &port9090,
Protocol: &protocolHTTP,
Expand Down Expand Up @@ -468,6 +471,44 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
TargetType: awssdk.String("ip"),
},
},
{
name: "standard case ipv6 address",
args: args{
tgSpec: elbv2model.TargetGroupSpec{
Name: "my-tg",
TargetType: elbv2model.TargetTypeIP,
Port: 8080,
Protocol: elbv2model.ProtocolHTTP,
IPAddressType: &ipAddressTypeIPv6,
HealthCheckConfig: &elbv2model.TargetGroupHealthCheckConfig{
Port: &port9090,
Protocol: &protocolHTTP,
Path: awssdk.String("/healthcheck"),
Matcher: &elbv2model.HealthCheckMatcher{HTTPCode: awssdk.String("200")},
IntervalSeconds: awssdk.Int64(10),
TimeoutSeconds: awssdk.Int64(5),
HealthyThresholdCount: awssdk.Int64(3),
UnhealthyThresholdCount: awssdk.Int64(2),
},
},
},
want: &elbv2sdk.CreateTargetGroupInput{
HealthCheckEnabled: awssdk.Bool(true),
HealthCheckIntervalSeconds: awssdk.Int64(10),
HealthCheckPath: awssdk.String("/healthcheck"),
HealthCheckPort: awssdk.String("9090"),
HealthCheckProtocol: awssdk.String("HTTP"),
HealthCheckTimeoutSeconds: awssdk.Int64(5),
HealthyThresholdCount: awssdk.Int64(3),
Matcher: &elbv2sdk.Matcher{HttpCode: awssdk.String("200")},
UnhealthyThresholdCount: awssdk.Int64(2),
Name: awssdk.String("my-tg"),
Port: awssdk.Int64(8080),
Protocol: awssdk.String("HTTP"),
TargetType: awssdk.String("ip"),
IpAddressType: awssdk.String("ipv6"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit ea78369

Please sign in to comment.