Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianklotz/468a240a75f4ae3e73bd52722f926acb to your computer and use it in GitHub Desktop.
Save christianklotz/468a240a75f4ae3e73bd52722f926acb to your computer and use it in GitHub Desktop.
AWS CloudFormation resource name character limit

Using custom resource names in CloudFormation can potentially cause resources' physical ids to exceed the allowed limit of 64 characters. Especially with nested stacks, as AWS::CloudFormation::Stack does not support custom names causing nested stacks to always be named automatically in the format <logical-id>-XXXXXXXXXXXX, with XXXXXXXXXXXX being a autogenerated identifier.

Below is an example of AWS::Lambda::Function within a nested CloudFormation stack.

With functionName

Physical resource id is generated using the following format.

<root-stack-name>-XXXXXXXXXXXX-<lambda-function-name>

Quickly exceeds max length 64 characters.

1 validation error detected: 

Value 'MyStackDev-MyNestedApplicationStack-K87FLFVLYVQJ-MyLambdaFunctionName' 
at 'functionName' failed to satisfy constraint: 

Member must have length less than or equal to 64 
(
    Service: AWSLambda; 
    Status Code: 400; 
    Error Code: InvalidParameterValueException; 
    Request ID: eab56570-8aaa-11e8-9306-c996c69bdf46
)

Without functionName

Physical resource id generated using the following format and trimmed to maximum of 64 characters.

<root-stack-name>-<nested-stack-logical-id>-XXXXXXXXXXXX

Automatic resource ID too long (70 characters)
MyStackDev-MyNestedApplicationStack-MyLambdaFunctionName-1U44TLUZ7OR55

Actual resource ID (64 characters)
MyStackDev-MyNestedApplicatio-MyLambdaFunctionName-1U44TLUZ7OR55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment