Skip to content

Commit 83a8c40

Browse files
authored
Merge pull request #2308 from kishorj/target-group-ipaddress
Create target group not explicity specify ipAddressType ipv4
2 parents 61d970b + ea78369 commit 83a8c40

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

pkg/deploy/elbv2/target_group_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func buildSDKCreateTargetGroupInput(tgSpec elbv2model.TargetGroupSpec) *elbv2sdk
192192
sdkObj.TargetType = awssdk.String(string(tgSpec.TargetType))
193193
sdkObj.Port = awssdk.Int64(tgSpec.Port)
194194
sdkObj.Protocol = awssdk.String(string(tgSpec.Protocol))
195-
if tgSpec.IPAddressType != nil {
195+
if tgSpec.IPAddressType != nil && *tgSpec.IPAddressType != elbv2model.TargetGroupIPAddressTypeIPv4 {
196196
sdkObj.IpAddressType = (*string)(tgSpec.IPAddressType)
197197
}
198198
if tgSpec.ProtocolVersion != nil {

pkg/deploy/elbv2/target_group_manager_test.go

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
386386
port9090 := intstr.FromInt(9090)
387387
protocolHTTP := elbv2model.ProtocolHTTP
388388
protocolVersionHTTP2 := elbv2model.ProtocolVersionHTTP2
389+
ipAddressTypeIPv4 := elbv2model.TargetGroupIPAddressTypeIPv4
390+
ipAddressTypeIPv6 := elbv2model.TargetGroupIPAddressTypeIPv6
389391
type args struct {
390392
tgSpec elbv2model.TargetGroupSpec
391393
}
@@ -398,10 +400,11 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
398400
name: "standard case",
399401
args: args{
400402
tgSpec: elbv2model.TargetGroupSpec{
401-
Name: "my-tg",
402-
TargetType: elbv2model.TargetTypeIP,
403-
Port: 8080,
404-
Protocol: elbv2model.ProtocolHTTP,
403+
Name: "my-tg",
404+
TargetType: elbv2model.TargetTypeIP,
405+
Port: 8080,
406+
Protocol: elbv2model.ProtocolHTTP,
407+
IPAddressType: &ipAddressTypeIPv4,
405408
HealthCheckConfig: &elbv2model.TargetGroupHealthCheckConfig{
406409
Port: &port9090,
407410
Protocol: &protocolHTTP,
@@ -468,6 +471,44 @@ func Test_buildSDKCreateTargetGroupInput(t *testing.T) {
468471
TargetType: awssdk.String("ip"),
469472
},
470473
},
474+
{
475+
name: "standard case ipv6 address",
476+
args: args{
477+
tgSpec: elbv2model.TargetGroupSpec{
478+
Name: "my-tg",
479+
TargetType: elbv2model.TargetTypeIP,
480+
Port: 8080,
481+
Protocol: elbv2model.ProtocolHTTP,
482+
IPAddressType: &ipAddressTypeIPv6,
483+
HealthCheckConfig: &elbv2model.TargetGroupHealthCheckConfig{
484+
Port: &port9090,
485+
Protocol: &protocolHTTP,
486+
Path: awssdk.String("/healthcheck"),
487+
Matcher: &elbv2model.HealthCheckMatcher{HTTPCode: awssdk.String("200")},
488+
IntervalSeconds: awssdk.Int64(10),
489+
TimeoutSeconds: awssdk.Int64(5),
490+
HealthyThresholdCount: awssdk.Int64(3),
491+
UnhealthyThresholdCount: awssdk.Int64(2),
492+
},
493+
},
494+
},
495+
want: &elbv2sdk.CreateTargetGroupInput{
496+
HealthCheckEnabled: awssdk.Bool(true),
497+
HealthCheckIntervalSeconds: awssdk.Int64(10),
498+
HealthCheckPath: awssdk.String("/healthcheck"),
499+
HealthCheckPort: awssdk.String("9090"),
500+
HealthCheckProtocol: awssdk.String("HTTP"),
501+
HealthCheckTimeoutSeconds: awssdk.Int64(5),
502+
HealthyThresholdCount: awssdk.Int64(3),
503+
Matcher: &elbv2sdk.Matcher{HttpCode: awssdk.String("200")},
504+
UnhealthyThresholdCount: awssdk.Int64(2),
505+
Name: awssdk.String("my-tg"),
506+
Port: awssdk.Int64(8080),
507+
Protocol: awssdk.String("HTTP"),
508+
TargetType: awssdk.String("ip"),
509+
IpAddressType: awssdk.String("ipv6"),
510+
},
511+
},
471512
}
472513
for _, tt := range tests {
473514
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)