Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 934
Jordan Morris Avatar asked Sep 05 '17 10:09

Jordan Morris


People also ask

Which AWS resources Cannot be tagged?

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.

Which two AWS services can break down AWS costs by tag?

AWS Cost Explorer and detailed billing reports let you break down AWS costs by tag.

What is AWS Resource tags?

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.

Which AWS service can be used to define and enforce required tags?

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.


1 Answers

1. AWS Lambda

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.

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]$)/
like image 123
mostafazh Avatar answered Sep 20 '22 07:09

mostafazh