微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

自动缩放 - 生命周期钩子实现

如何解决自动缩放 - 生命周期钩子实现

我正在尝试使用生命周期钩子实现我的第一个 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
        }
    }

非常感谢您的帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。