PutLifecycleHook 操作:无法将测试消息发布到通知目标 (FIFO)

PutLifecycleHook operation: Unable to publish test message to notification target (FIFO)

有许多文档解释了如何解决此错误。检查了其中的许多并尝试了。但是跟随他们并不能为我解决这个问题。

我得到的错误是

An error occurred (ValidationError) when calling the PutLifecycleHook operation: Unable to publish test message to notification target arn:aws:sqs:xxxxx:XXXXX:kubeeventsqueue.fifo using IAM role arn:aws:iam::XXXXXXXXX:role/kubeautoscaling. Please check your target and role configuration and try to put lifecycle hook again.

我使用的命令是:

aws autoscaling put-lifecycle-hook --lifecycle-hook-name terminate --auto-scaling-group-name mygroupname --lifecycle-transition autoscaling:EC2_INSTANCE_TERMINATING --role-arn arn:aws:iam::XXXXXX:role/kubeautoscaling --notification-target-arn arn:aws:sqs:xxxxx:XXXXXXX:kubeeventsqueue.fifo

请注意,我已将上面的实际 ID 替换为 XXXXX。

相关角色(arn:aws:iam::XXXXXX:role/kubeautoscaling)与autoscaling.amazonaws.com有信任关系。它还附加了 "AutoScalingNotificationAccessRole" 政策。

在测试时,我还尝试为所有 SQS 操作 (SQS:*) 添加 "Allow everybody" 权限。 (尽管在测试后将其删除)。

我也尝试过先创建 SQS 队列然后配置 --notification-target-arn,但没有成功。

对此的任何帮助都会非常有帮助。

看来您正在使用 Amazon SQS FIFO(先进先出)队列。

来自Configuring Notifications for Amazon EC2 Auto Scaling Lifecycle Hooks - Receive Notification Using Amazon SQS

FIFO queues are not compatible with lifecycle hooks.

我不知道这是否是您当前错误的原因,但它会阻止您所需的配置工作。

是的,LifeCycleHooks 绝对不支持 FIFO 队列。我浪费了很多时间在权限和队列配置上,最终发现不支持 FIFO。如果这在文档中更加突出,那就太好了,因为 1) 它不明显或不直观,以及 2) 收到的错误消息表明它是权限之类的。明确声明“不支持 FIFO 队列”而不是“发送测试消息失败...”怎么样?太荒谬了!