Skip to content

Commit

Permalink
Merge pull request #33405 from hashicorp/b-lightsail-fix-name-validation
Browse files Browse the repository at this point in the history
lightsail: Fix regex name validation
  • Loading branch information
YakDriver authored Sep 11, 2023
2 parents 599628a + 20d6bea commit dd0a070
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 11 deletions.
39 changes: 39 additions & 0 deletions .changelog/33405.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
```release-note:bug
resource/aws_lightsail_certificate: Fix validation of `name`
```

```release-note:bug
resource/aws_lightsail_database: Fix validation of `name`
```

```release-note:bug
resource/aws_lightsail_disk: Fix validation of `name`
```

```release-note:bug
resource/aws_lightsail_instance: Fix validation of `name`
```

```release-note:bug
resource/aws_lightsail_lb: Fix validation of `lb_name`
```

```release-note:bug
resource/aws_lightsail_lb_attachment: Fix validation of `lb_name`
```

```release-note:bug
resource/aws_lightsail_lb_certificate: Fix validation of `lb_name`
```

```release-note:bug
resource/aws_lightsail_lb_certificate_attachment: Fix validation of `lb_name`
```

```release-note:bug
resource/aws_lightsail_lb_https_redirection_policy: Fix validation of `lb_name`
```

```release-note:bug
resource/aws_lightsail_lb_stickiness_policy: Fix validation of `lb_name`
```
2 changes: 1 addition & 1 deletion internal/service/lightsail/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func ResourceCertificate() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"subject_alternative_names": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func ResourceDatabase() *schema.Resource {
ForceNew: true,
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[_.^-]+[0-9A-Za-z-]+[_.^-]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"),
validation.StringMatch(regexache.MustCompile(`^[^_.-]+[0-9A-Za-z-]+[^_.-]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"),
),
},
"secondary_availability_zone": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ResourceDisk() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"size_in_gb": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ResourceInstance() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]`), "must begin with an alphanumeric character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"availability_zone": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func ResourceLoadBalancer() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"support_code": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/lb_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func ResourceLoadBalancerAttachment() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"instance_name": {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/lightsail/lb_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func ResourceLoadBalancerCertificate() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"name": {
Expand All @@ -97,7 +97,7 @@ func ResourceLoadBalancerCertificate() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"subject_alternative_names": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/lb_certificate_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ResourceLoadBalancerCertificateAttachment() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
"certificate_name": {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/lb_https_redirection_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func ResourceLoadBalancerHTTPSRedirectionPolicy() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lightsail/lb_stickiness_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func ResourceLoadBalancerStickinessPolicy() *schema.Resource {
ValidateFunc: validation.All(
validation.StringLenBetween(2, 255),
validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[^_.-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"),
),
},
},
Expand Down

0 comments on commit dd0a070

Please sign in to comment.