4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

failed to satisfy constraint: Member must have length less than or equal to 64

Posted at

事象 : CloudFormationでEventBridgeのRuleを登録したらエラー

テンプレートファイルにEventBridgeのルールを追加して・・・

アップロードしたテンプレートファイル
# ...省略...
EventBridgeRuleCase1:
    Type: AWS::Events::Rule
    Properties:
      Name: !Sub ${AWS::StackName}-event-bridge-rule-long-long-long-long-name
      ScheduleExpression: 'cron(0 12 * * ? *)'
      Targets:
        - Arn: !GetAtt Cluster.Arn
          RoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/ecsEventsRole
          Id: !Sub ${AWS::StackName}-event-bridge-rule-long-long-long-long-name
# ...省略...

CloudFormationのスタックをテンプレートファイルで更新・・・しらたエラーになりました。
image.png

エラーメッセージ
1 validation error detected: Value 'ecs-cluster-very-long-long-name-event-bridge-rule-long-long-long-long-name' at 'name' failed to satisfy constraint: Member must have length less than or equal to 64 (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: 6xxxxx-xxxx-xxx-xxxxxx; Proxy: null)

原因 : ルールのNameは文字数上限が64文字までだから

擬似パラメーターAWS::StackNameにはECSのクラスター名が入ります。
結果、ルール名は70文字近くになっていました。

Name
The name of the rule.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern: [.-_A-Za-z0-9]+
Required: No
Rule - Amazon EventBridge

TargetのIdも同じく64文字まででした。

Id
The ID of the target within the specified rule. Use this ID to reference the target when updating the rule. We recommend using a memorable and unique string.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern: [.-_A-Za-z0-9]+
Required: Yes
Target - Amazon EventBridge

対応 : NameとIdを短くする

修正したテンプレートファイル
# ...省略...
    Properties:
      Name: !Sub ${AWS::StackName}-event-bridge-rule-name
# ...省略...
          Id: !Sub ${AWS::StackName}-event-bridge-rule-name
# ...省略...
  1. テンプレートファイルを短い文字列へ修正
  2. CloudFormationで今一度アップロードして登録
  3. 成功
  4. 戒め : 文字数制限はちゃんと確認する、特に擬似パラメーターを使うときは。
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?