Skip to content

Commit

Permalink
chore: remove udp and tcp_udp for LBWS (#3224)
Browse files Browse the repository at this point in the history
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
Lou1415926 authored Jan 26, 2022
1 parent 7dfd222 commit 060b8d1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/cli/svc_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func TestSvcDeployOpts_deploySvc(t *testing.T) {
"fail to get public CIDR blocks": {
inBuildRequire: false,
inNLB: manifest.NetworkLoadBalancerConfiguration{
Port: aws.String("443/udp"),
Port: aws.String("443/tls"),
},
inEnvironment: &config.Environment{
Name: mockEnvName,
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/deploy/cloudformation/stack/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
defaultIAM = disabled
defaultReadOnly = true
defaultWritePermission = false
defaultNLBProtocol = manifest.TCPUDP
defaultNLBProtocol = manifest.TCP
)

// Supported capacityproviders for Fargate services
Expand Down
10 changes: 4 additions & 6 deletions internal/pkg/manifest/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ const (
)

const (
TCPUDP = "TCP_UDP"
tcp = "TCP"
udp = "UDP"
tls = "TLS"
TCP = "TCP"
tls = "TLS"
)

var validProtocols = []string{TCPUDP, tcp, udp, tls}
var validProtocols = []string{TCP, tls}

var (
intRangeBandRegexp = regexp.MustCompile(`^(\d+)-(\d+)$`)
Expand Down Expand Up @@ -671,7 +669,7 @@ func validateNLBPort(port *string) error {
}
}
if !isValidProtocol {
return fmt.Errorf(`unrecognized protocol %s`, protocolVal)
return fmt.Errorf(`invalid protocol %s; valid protocols include %s`, protocolVal, english.WordSeries(validProtocols, "and"))
}
return nil
}
Expand Down
10 changes: 6 additions & 4 deletions internal/pkg/manifest/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,32 +1102,34 @@ func TestNetworkLoadBalancerConfiguration_Validate(t *testing.T) {
Port: aws.String("443"),
},
},
"error if protocol is not recognized": {
"fail if protocol is not recognized": {
nlb: NetworkLoadBalancerConfiguration{
Port: aws.String("443/tps"),
},
wantedErrorMsgPrefix: `validate "nlb": `,
wantedError: fmt.Errorf(`validate "port": unrecognized protocol tps`),
wantedError: fmt.Errorf(`validate "port": invalid protocol tps; valid protocols include TCP and TLS`),
},
"success if tcp": {
nlb: NetworkLoadBalancerConfiguration{
Port: aws.String("443/tcp"),
},
},
"success if udp": {
"error if udp": {
nlb: NetworkLoadBalancerConfiguration{
Port: aws.String("161/udp"),
},
wantedError: fmt.Errorf(`validate "port": invalid protocol udp; valid protocols include TCP and TLS`),
},
"success if tls": {
nlb: NetworkLoadBalancerConfiguration{
Port: aws.String("443/tls"),
},
},
"success if tcp_udp": {
"error if tcp_udp": {
nlb: NetworkLoadBalancerConfiguration{
Port: aws.String("443/TCP_udp"),
},
wantedError: fmt.Errorf(`validate "port": invalid protocol TCP_udp; valid protocols include TCP and TLS`),
},
}

Expand Down
15 changes: 0 additions & 15 deletions internal/pkg/template/templates/workloads/partials/cf/nlb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ NLBTargetGroup:
Value: {{ .NLB.Listener.Stickiness }}
{{- end}}
{{- end}}
- Key: deregistration_delay.connection_termination.enabled {{/* It is recommended to have this enabled for UDP and TCP_UDP target groups */}}
Value: {{- if or (eq $.NLB.Listener.Protocol "UDP") (eq $.NLB.Listener.Protocol "TCP_UDP") }} true {{- else}} false {{- end}}
TargetType: ip
VpcId:
Fn::ImportValue:
Expand All @@ -72,24 +70,11 @@ NLBSecurityGroup:
GroupDescription: Allow access from the network load balancer to service
SecurityGroupIngress:
{{range $cidr := .NLB.PublicSubnetCIDRs}}
{{- if eq $.NLB.Listener.Protocol "TCP_UDP" }}
- CidrIp: {{$cidr}}
Description: Ingress to allow access from Network Load Balancer subnet
FromPort: {{ $.NLB.Listener.TargetPort }}
IpProtocol: TCP
ToPort: {{ $.NLB.Listener.TargetPort }}
- CidrIp: {{$cidr}}
Description: Ingress to allow access from Network Load Balancer subnet
FromPort: {{ $.NLB.Listener.TargetPort }}
IpProtocol: UDP
ToPort: {{ $.NLB.Listener.TargetPort }}
{{- else }}
- CidrIp: {{$cidr}}
Description: Ingress to allow access from Network Load Balancer subnet
FromPort: {{ $.NLB.Listener.TargetPort }}
IpProtocol: {{- if eq $.NLB.Listener.Protocol "TLS" }} TCP {{- else }} {{ $.NLB.Listener.Protocol }} {{- end}}
ToPort: {{ $.NLB.Listener.TargetPort }}
{{- end }}
{{- if $.NLB.Listener.HealthCheck.Port}}{{- if ne $.NLB.Listener.HealthCheck.Port $.NLB.Listener.Port}}
- CidrIp: {{$cidr}}
Description: Ingress to allow access from Network Load Balancer subnet for health check
Expand Down

0 comments on commit 060b8d1

Please sign in to comment.