Skip to content

Storage init fails due to validateKey #2134

@ghost

Description

When creating DynamoDB with the following options(the length of attribute name is 2):
$ copilot storage init -n todotable -t "DynamoDB" -w backend --partition-key Id:S --no-lsi --no-sort

Copilot throws the following error:
✘ value must contain only alphanumeric characters and ._-

If the length of DynamoDB table's attribute name is longer like following:
$ copilot storage init -n todotable -t "DynamoDB" -w backend --partition-key TodoId:S --no-lsi --no-sort

Copilot wrote CFn template successfully.
✔ Wrote CloudFormation template for DynamoDB Table todotable at copilot/backend/addons/todotable.yml

According to DynamoDB's naming rule(https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.NamingRules ), attribute names must be at least one character long.

Validation for the length of partition key name is needed in validateKey function

func validateKey(val interface{}) error {

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugIssues that are bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions