【问题标题】:cloudformation lifecycle events cannot publish to snscloudformation 生命周期事件无法发布到 sns
【发布时间】:2018-06-05 19:52:03
【问题描述】:

我正在尝试为 AWS Amazon cloudformation 中的自动缩放组创建一个生命周期事件,但是在部署我的堆栈时我不断收到一个非常模糊的错误:

Unable to publish test message to notification target arn:aws:sns:us-east-1:000000000000:example-topic using IAM role arn:aws:iam::000000000000:role/SNSExample. Please check your target and role configuration and try to put lifecycle hook again.

我已经测试了 SNS 主题,它可以很好地发送电子邮件,我的代码似乎符合亚马逊的建议:

"ASGLifecycleEvent": {
  "Type": "AWS::AutoScaling::LifecycleHook",
  "Properties": {
    "AutoScalingGroupName": "ASG-179ZOVNY8SEFT",
    "LifecycleTransition": "autoscaling:EC2_INSTANCE_LAUNCHING",
    "NotificationTargetARN": "arn:aws:sns:us-east-1:000000000000:example-topic",
    "RoleARN": "arn:aws:iam::000000000000:role/SNSExample"
  },
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "id": "83129091-8efc-477d-86ef-9a08de4d6fac"
    }
  }
}

我已授予该 IAM 角色中所有内容的完全访问权限,但我仍然收到此错误消息。有没有人有任何其他想法可能真正导致此错误?

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-cloudformation


    【解决方案1】:

    您的SNSExample 角色需要通过关联的信任策略(CloudFormation 资源中的AssumeRolePolicyDocument 属性)将AutoScalingNotificationAccessRole 托管策略的权限委派给autoscaling.amazonaws.com 服务:

      SNSExample:
        Type: AWS::IAM::Role
        Properties:
          AssumeRolePolicyDocument:
            Statement:
            - Effect: Allow
              Principal:
                Service: [autoscaling.amazonaws.com]
              Action: ['sts:AssumeRole']
          Path: /
          ManagedPolicyArns:
          - arn:aws:iam::aws:policy/service-role/AutoScalingNotificationAccessRole
    

    (您也可以委派对 sns:Publish 操作的访问权限,而不是使用托管策略,但我建议使用托管策略,因为如果将来此服务需要其他权限,它会保持最新状态。)

    有关详细信息,请参阅 Auto Scaling 用户指南的 Auto Scaling 生命周期挂钩部分的 Receive Notification Using Amazon SNS 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-01
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      相关资源
      最近更新 更多