自动缩放 - lifecylehook 实现

自动缩放 - lifecylehook 实现

我正在尝试使用生命周期挂钩实现我的第一个 ASG,但遇到了这个问题:

LifecycleHandlerFunction:遇到不支持的属性角色以下资源无法创建:[LifecycleHandlerFunction]。用户请求回滚。

我不知道我做错了什么。我正在使用这个代码示例:https://github.com/aws-samples/ecs-refarch-cloudformation/blob/master/infrastructure/lifecyclehook.yaml

AutoscalingNotificationRole 和 LambdaExecutionRole 已在我的 aws 账户中设置。

"NotificationTopic": {
        "Type": "AWS::SNS::Topic",
        "Properties": {
          "Subscription": [
            {
              "Endpoint": {
                "Fn::GetAtt": [
                "LifecycleHandlerFunction",
                "Arn"
                ]
              },
              "Protocol": "lambda"
            }
          ]   
        },
        "DependsOn": "LifecycleHandlerFunction"
    },
    "InstanceTerminatingHook": {
      "Type": "AWS::AutoScaling::LifecycleHook",
      "Properties": {
        "AutoScalingGroupName": {
            "Fn::Join": [
                "",
                [
                    { "Ref": "ClusterName" }, "-autoscaling"
                ]
            ]
        },
        "DefaultResult": "ABANDON",
        "HeartbeatTimeout": "900",
        "LifecycleTransition": "autoscaling:EC2_INSTANCE_TERMINATING",
        "NotificationTargetARN": "NotificationTopic",
        "RoleARN": [ 
            "AutoscalingNotificationRole", 
            "Arn" 
        ]
      },
      "DependsOn": "NotificationTopic"
    },
    "LambdaInvokePermission": {
      "Type": "AWS::Lambda::Permission",
      "Properties": {
        "FunctionName": "LifecycleHandlerFunction",
        "Action": "lambda:InvokeFunction",
        "Principal": "sns.amazonaws.com",
        "SourceArn": { "Ref": "NotificationTopic" }
      }
    },
    "LifecycleHandlerFunction": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Environment": {
          "Variables": {
            "CLUSTER": { "Ref": "ClusterName" }
        },
        "Handler": "index.lambda_handler",
        "Role": [ 
            "LambdaAutoscalingExecutionRole",
            "Arn"
        ],
        "Code": {
          "ZipFile": [
              "",
              [
                "my python code"
              ]
            ]
        },
        "Runtime": "python3.6",
        "Timeout": 10
        }
    }

非常感谢您的帮助。

相关内容