Skip to content

Commit 334ffcf

Browse files
authored
Add non-alphanumeric input validation test for vpcID and fix typo (#3687)
* Add non-alphanumeric input validation test for vpcID * Fix cert arn typo and add docs for cert arn support in IngressClassParams
1 parent 3bbfb9d commit 334ffcf

File tree

10 files changed

+36
-16
lines changed

10 files changed

+36
-16
lines changed

apis/elbv2/v1beta1/ingressclassparams_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ type Attribute struct {
8686

8787
// IngressClassParamsSpec defines the desired state of IngressClassParams
8888
type IngressClassParamsSpec struct {
89-
// CertificateARN specifies the ARN of the certificates for all Ingresses that belong to IngressClass with this IngressClassParams.
89+
// CertificateArn specifies the ARN of the certificates for all Ingresses that belong to IngressClass with this IngressClassParams.
9090
// +optional
91-
CertficateArn []string `json:"certficateArn,omitempty"`
91+
CertificateArn []string `json:"certificateArn,omitempty"`
9292

9393
// NamespaceSelector restrict the namespaces of Ingresses that are allowed to specify the IngressClass with this IngressClassParams.
9494
// * if absent or present but empty, it selects all namespaces.

apis/elbv2/v1beta1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/elbv2.k8s.aws_ingressclassparams.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ spec:
5555
spec:
5656
description: IngressClassParamsSpec defines the desired state of IngressClassParams
5757
properties:
58-
certficateArn:
59-
description: CertificateARN specifies the ARN of the certificates
58+
certificateArn:
59+
description: CertificateArn specifies the ARN of the certificates
6060
for all Ingresses that belong to IngressClass with this IngressClassParams.
6161
items:
6262
type: string

docs/guide/ingress/cert_discovery.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Certificate Discovery
2-
TLS certificates for ALB Listeners can be automatically discovered with hostnames from Ingress resources if the [`alb.ingress.kubernetes.io/certificate-arn`](annotations.md#certificate-arn) annotation is not specified.
2+
TLS certificates for ALB Listeners can be automatically discovered with hostnames from Ingress resources if the [`spec.certificateArn`](ingress_class.md#speccertificatearn) in [`IngressClassParams`](ingress_class.md#ingressclassparams-specification) or [`alb.ingress.kubernetes.io/certificate-arn`](annotations.md#certificate-arn) annotation is not specified.
33

44
The controller will attempt to discover TLS certificates from the `tls` field in Ingress and `host` field in Ingress rules.
55

docs/guide/ingress/ingress_class.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ You can use IngressClassParams to enforce settings for a set of Ingresses.
131131
- myVal0
132132
- myVal1
133133
```
134+
- with certificateArn
135+
```
136+
apiVersion: elbv2.k8s.aws/v1beta1
137+
kind: IngressClassParams
138+
metadata:
139+
name: class2048-config
140+
spec:
141+
certificateArn: ['arn:aws:acm:us-east-1:123456789:certificate/test-arn-1','arn:aws:acm:us-east-1:123456789:certificate/test-arn-2']
142+
```
134143

135144
### IngressClassParams specification
136145

@@ -167,7 +176,7 @@ Cluster administrators can use the `scheme` field to restrict the scheme for all
167176
Cluster administrators can use the optional `inboundCIDRs` field to specify the CIDRs that are allowed to access the load balancers that belong to this IngressClass.
168177
If the field is specified, LBC will ignore the `alb.ingress.kubernetes.io/inbound-cidrs` annotation.
169178

170-
### spec.certificateArn
179+
#### spec.certificateArn
171180
Cluster administrators can use the optional `certificateARN` field to specify the ARN of the certificates for all Ingresses that belong to IngressClass with this IngressClassParams.
172181

173182
If the field is specified, LBC will ignore the `alb.ingress.kubernetes.io/certificate-arn` annotation.

helm/aws-load-balancer-controller/crds/crds.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ spec:
5454
spec:
5555
description: IngressClassParamsSpec defines the desired state of IngressClassParams
5656
properties:
57-
certficateArn:
58-
description:
59-
CertificateARN specifies the ARN of the certificates for
60-
all Ingresses that belong to IngressClass with this IngressClassParams.
57+
certificateArn:
58+
description: CertificateArn specifies the ARN of the certificates
59+
for all Ingresses that belong to IngressClass with this IngressClassParams.
6160
items:
6261
type: string
6362
type: array

pkg/annotations/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ const (
8787
SvcLBSuffixLoadBalancerSecurityGroups = "aws-load-balancer-security-groups"
8888
SvcLBSuffixManageSGRules = "aws-load-balancer-manage-backend-security-group-rules"
8989
SvcLBSuffixEnforceSGInboundRulesOnPrivateLinkTraffic = "aws-load-balancer-inbound-sg-rules-on-private-link-traffic"
90-
SvcLBSuffixSecurityGroupPrefixLists = "aws-load-balancer-security-group-prefix-lists"
90+
SvcLBSuffixSecurityGroupPrefixLists = "aws-load-balancer-security-group-prefix-lists"
9191
)

pkg/ingress/model_build_listener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func (t *defaultModelBuildTask) computeIngressListenPortConfigByPort(ctx context
167167
}
168168

169169
func (t *defaultModelBuildTask) computeIngressExplicitTLSCertARNs(_ context.Context, ing *ClassifiedIngress) []string {
170-
if ing.IngClassConfig.IngClassParams != nil && len(ing.IngClassConfig.IngClassParams.Spec.CertficateArn) != 0 {
171-
return ing.IngClassConfig.IngClassParams.Spec.CertficateArn
170+
if ing.IngClassConfig.IngClassParams != nil && len(ing.IngClassConfig.IngClassParams.Spec.CertificateArn) != 0 {
171+
return ing.IngClassConfig.IngClassParams.Spec.CertificateArn
172172
}
173173
var rawTLSCertARNs []string
174174
_ = t.annotationParser.ParseStringSliceAnnotation(annotations.IngressSuffixCertificateARN, &rawTLSCertARNs, ing.Ing.Annotations)

pkg/ingress/model_builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
18961896
IngClassConfig: ClassConfiguration{
18971897
IngClassParams: &v1beta1.IngressClassParams{
18981898
Spec: v1beta1.IngressClassParamsSpec{
1899-
CertficateArn: []string{"arn:aws:acm:us-east-1:9999999:certificate/ingress-class-certificate-arn"},
1899+
CertificateArn: []string{"arn:aws:acm:us-east-1:9999999:certificate/ingress-class-certificate-arn"},
19001900
},
19011901
},
19021902
},

webhooks/elbv2/targetgroupbinding_validator_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,18 @@ func Test_targetGroupBindingValidator_checkTargetGroupVpcID(t *testing.T) {
11361136
},
11371137
wantErr: errors.New("ValidationError: vpcID vpcid-123 failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers."),
11381138
},
1139+
{
1140+
name: "[err] vpcID is not valid - non alphanumeric value",
1141+
args: args{
1142+
obj: &elbv2api.TargetGroupBinding{
1143+
Spec: elbv2api.TargetGroupBindingSpec{
1144+
TargetGroupARN: "tg-2",
1145+
VpcID: "vpcid-@34!dv",
1146+
},
1147+
},
1148+
},
1149+
wantErr: errors.New("ValidationError: vpcID vpcid-@34!dv failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers."),
1150+
},
11391151
}
11401152
for _, tt := range tests {
11411153
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)