Skip to content

Deployment fails due to AWS::Events::Rule name length limit (64 chars) when deploying via StackSets #36

@k-okuya

Description

@k-okuya

Description

I encountered a deployment failure when deploying this template using AWS CloudFormation StackSets.
The error occurs because the generated name for AWS::Events::Rule exceeds the service limit of 64 characters.

This happens particularly when the StackSet name itself is long, as the AWS::Events::Rule resource in the template inherits the name from the SQS queue (SQSConfigRecorder), which allows up to 80 characters, causing a mismatch with the EventBridge limit.

Error Log

ResourceLogicalId: ProducerEventTrigger
ResourceType: AWS::Events::Rule
ResourceStatusReason: Resource handler returned message: "1 validation error detected: Value 'StackSet-master-config-exclusion-cfn-bb504b54-5f7-SQSConfigRecorder-PgvEuTNmRU9F' at 'name' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: EventBridge, Status Code: 400 ...)"

Root Cause

In the ProducerEventTrigger resource, the Name property is set to retrieve the SQS Queue Name:

  ProducerEventTrigger:
    Type: AWS::Events::Rule
    Properties:
      # ...
      Name: !GetAtt SQSConfigRecorder.QueueName  <-- CAUSE

When deployed via StackSets, CloudFormation automatically appends prefixes (e.g., StackSet-xxx-...) and random strings to the SQS queue name. SQS allows up to 80 characters, but EventBridge Rules are strictly limited to 64 characters. In my case, the generated SQS name was 86 characters long, resulting in the validation error.

Suggested Fix

To ensure the name stays within the 64-character limit, I recommend explicitly specifying a shorter, fixed name or using a truncated naming logic for the EventBridge Rule, rather than inheriting the full SQS queue name.

Example Fix:

  ProducerEventTrigger:
    Type: AWS::Events::Rule
    Properties:
      # Use a fixed short name or generate a shorter custom name
      Name: "ct-config-recorder-trigger" 
      # ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions