Different resources in aws, such as S3 buckets, lambdas and roles, have different maximum lengths and different character sets which they accept.
Is there a very restrictive resource name, which, if you follow it, you will also be obeying the restrictions of all other resources?
I'm looking for a set of constraints which will obey every kind of restriction enforced by all resource groups, globally, yet also be as permissive as possible.
The ideal answer would be a nice, unambiguous regular expression.
For example - services like ec2,s3,lambda,dynamodb - has tagging feature, so that resources can be identified by tags(assuming they are tagged). Services like sns,sqs - do not have tagging option.
AWS Cost Explorer and detailed billing reports let you break down AWS costs by tag.
A tag is a label that you assign to an AWS resource. Each tag consists of a key and an optional value, both of which you define. Tags enable you to categorize your AWS resources in different ways, for example, by purpose, owner, or environment.
Enforce Centralized Tag Compliance Using AWS Service Catalog, DynamoDB, Lambda, and CloudWatch Events. Some of the customers we work with have a central database where they keep tag values, and they want to enforce tags at provisioning using the tag enforcement capability of AWS Service Catalog.
Function name must contain only letters, numbers, hyphens, or underscores
This field is too long. Maximum length is 140 characters.
This field is too short. Minimum length is 1 character.
source: AWS Lambda "Create Function" Page & API docs.
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.
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.
/(?=.{3,63}$)(?!-)(?!.*--)[a-z0-9-]+(?<!-)/
Read this and this for better understand the regex above.
/(^[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]$)/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With