diff --git a/.changelog/10693.txt b/.changelog/10693.txt new file mode 100644 index 00000000000..842c2df5ca0 --- /dev/null +++ b/.changelog/10693.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_lb: Update `name` and `name_prefix` plan-time validation to exclude `"internal-"` +``` diff --git a/internal/service/elbv2/validate.go b/internal/service/elbv2/validate.go index 718f76a7118..a8923d4645a 100644 --- a/internal/service/elbv2/validate.go +++ b/internal/service/elbv2/validate.go @@ -29,6 +29,10 @@ func validName(v interface{}, k string) (ws []string, errors []error) { errors = append(errors, fmt.Errorf( "%q cannot end with a hyphen: %q", k, value)) } + if regexp.MustCompile(`^internal-`).MatchString(value) { + errors = append(errors, fmt.Errorf( + `%q cannot begin with "internal-": %q`, k, value)) + } return } @@ -47,6 +51,10 @@ func validNamePrefix(v interface{}, k string) (ws []string, errors []error) { errors = append(errors, fmt.Errorf( "%q cannot begin with a hyphen: %q", k, value)) } + if regexp.MustCompile(`^internal-`).MatchString(value) { + errors = append(errors, fmt.Errorf( + `%q cannot begin with "internal-": %q`, k, value)) + } return } diff --git a/internal/service/elbv2/validate_test.go b/internal/service/elbv2/validate_test.go index 49a30cc7e44..72dd9c1c5f6 100644 --- a/internal/service/elbv2/validate_test.go +++ b/internal/service/elbv2/validate_test.go @@ -23,6 +23,7 @@ func TestValidName(t *testing.T) { "tf-test-elb-tf-test-elb-tf-test-elb", "-tf-test-elb", "tf-test-elb-", + "internal-tf-test-elb", } for _, s := range invalidNames { @@ -49,6 +50,7 @@ func TestValidNamePrefix(t *testing.T) { "tf.test.elb.", "tf-test", "-test", + "internal-", } for _, s := range invalidNamePrefixes {