Skip to content

Create target group not explicity specify ipAddressType ipv4 #2308

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

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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