Resources: ABLStack: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://s3.amazonaws.com/example/stack.yml Parameters: ResouceID: Ref: WrongID
在上面的示例中,错误的资源ID将导致健康检查失败。请确保资源ID正确匹配。
Resources: LoadBalancer: Type: AWS::ElasticLoadBalancing::LoadBalancer Properties: Instances: - Ref: EC2Instance Listeners: - LoadBalancerPort: '80' InstancePort: '80' Protocol: HTTP HealthCheck: Target: TCP:8081 HealthyThreshold: '2' UnhealthyThreshold: '5' Interval: '30' Timeout: '5'
在上面的示例中,应用程序监听端口为80,但健康检查端口为8081,这可能会导致健康检查失败。请确保健康检查端口正确匹配。
UserData: Fn::Base64: !Sub | #!/bin/bash until curl -Is http://localhost:8080 | head -1 | grep "200 OK"; do echo "Waiting for server to start..." sleep 5 done
在上面的示例中,直到应用程序返回200 OK响应为止,脚本将等待应用程序启动