New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws/provider: add validation function to the tagsSchema #12127

wants to merge 2 commits into
base: master
Jump to file or symbol
Failed to load files and symbols.
+20 −2
Diff settings


Just for now

@@ -1,6 +1,7 @@
package aws
import (
@@ -19,8 +20,9 @@ import (
func tagsSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Type: schema.TypeMap,
Optional: true,
ValidateFunc: validateTags,
@@ -348,3 +350,19 @@ func diffTagsDynamoDb(oldTags, newTags []*dynamodb.Tag) ([]*dynamodb.Tag, []*str
return tagsFromMapDynamoDb(create), remove
func validateTags(v interface{}, k string) (ws []string, errors []error) {
m := v.(map[string]interface{})
for key, value := range m {
if len(key) > 127 {
errors = append(errors, fmt.Errorf("tag %q name cannot be longer than '127' characters", key))
if len(value.(string)) > 255 {
errors = append(errors, fmt.Errorf("tag %q value %q cannot be longer than '255' characters", key, value.(string)))
if !regexp.MustCompile(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`).MatchString(value.(string)) {
errors = append(errors, fmt.Errorf("tag %q value %q contains invalid characters (must match this regex ^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$)", k, value.(string)))
ProTip! Use n and p to navigate between commits in a pull request.