Skip to content
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

Node.of(this).uniqueId is bound to CloudFormation's logical ID rules #250

Closed
foriequal0 opened this issue Sep 22, 2020 · 1 comment
Closed

Comments

@foriequal0
Copy link

foriequal0 commented Sep 22, 2020

I understand that constructs were supposed to support cdk, so It was also understandable that Node.of(this).uniqueId is bound to CloudFormation's logical ID rules:
([A-Za-z0-9]{255})
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html#resources-section-structure-resource-fields
https://docs.amazonaws.cn/en_us/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html

However, constructs is now also used as a foundation of cdk8s, and Kubernetes imposes different rules to resource names and labels:

DNS Subdomain Names

Most resource types require a name that can be used as a DNS subdomain name as defined in RFC 1123. This means the name must:

  • contain no more than 253 characters
  • contain only lowercase alphanumeric characters, '-' or '.'
  • start with an alphanumeric character
  • end with an alphanumeric character

DNS Label Names

Some resource types require their names to follow the DNS label standard as defined in RFC 1123. This means the name must:

  • contain at most 63 characters
  • contain only lowercase alphanumeric characters or '-'
  • start with an alphanumeric character
  • end with an alphanumeric character

https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names

Valid label keys have two segments: an optional prefix and name, separated by a slash (/). The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between. The prefix is optional. If specified, the prefix must be a DNS subdomain (...)

Valid label values must be 63 characters or less and must be empty or begin and end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.), and alphanumerics between.

https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

Some CF names might exceed K8s' name length limit, and contain upper case letters, and some K8s names/labels might contain invalid characters for CF ('-', '_', '.', '_')

Removing Node.of(this).uniqueId from constructs and letting cdk and cdk8s to implement their own uniqueId would prevent confusions and unnecessary limits on each frameworks.

Maybe this is related to this: #120

@eladb
Copy link
Contributor

eladb commented Dec 3, 2020

The new addr property should be used to generate unique IDs (see #314).

Resolved by #314

@eladb eladb closed this as completed Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants