What are the most restrictive aws resource name limitations (e.g. characters and length)?

1. AWS Lambda

Function name must contain only letters, numbers, hyphens, or underscores

This field is too long. Maximum length is 64 characters.

This field is too short. Minimum length is 1 character.

source: AWS Lambda "Create Function" Page & API docs.

2. S3 Bucket:

Bucket name must NOT contain uppercase characters or underscores

Bucket name must be between 3 and 63 characters long

source: AWS S3 "Create Bucket" Page & API docs.

3. RDS

Must contain 1 to 63 alphanumeric characters or hyphens.

First character must be a letter.

Cannot end with a hyphen or contain two consecutive hyphens.

source: AWS RDS docs

So adding only the 3 services above we can conclude that it's best to be:

Only lowercase alphanumeric characters and hyphens.

Minimum of 3 characters and maximum of 63.

First character must be a letter, cannot end with a hyphen or contain two consecutive hyphens.

I'd also suggest subtracting a common prefix (i.e. company name initials, "google-") from the maximum length to avoid running into issues when trying to create a bucket (or any AWS wide name) that could happen with a valid common name = "john"

Also looking at the IAM username and roles length restrictions (found here), nothing seems to conflict with the above conclusion.

Regex #1 (for advanced regex engines w/ lookahead support)

 /(?=.{3,63}$)(?!-)(?!.*--)[a-z0-9-]+(?<!-)/

Read this and this for better understand the regex above.

Regex #2

 /(^[a-z\d]{1,2}((-[a-z\d])|([a-z\d]{1,2})){0,30}[a-z\d]$)|(^[‌​a-z\d]((-[a-z\d])|([‌​a-z\d]{1,2})){0,30}[‌​a-z\d-]?[a-z\d]$)/