我的AWS CloudFormation模板失败并显示错误:
收到0个SUCCESS信号1.无法满足100% MinSuccessfulInstancesPercent要求
我认为我的WaitConditionHandles设置不正确(或者EC2实例可能没有发送),但不知道如何解决这个问题。
所有内容(ASG,EC2实例)似乎都在AWS中正确创建。
我正在使用以下CloudFormation模板:
AWSTemplateFormatVersion: "2010-09-09"
Description: "Auto Scaling Group"
Outputs:
AsgArn:
Value: !Ref "AutoScalingGroup"
AsgMinSize:
Description: "The minimum size of the Auto Scaling Group"
Value: !FindInMap [ "HighAvailability", "MinSize", !Ref "HighAvailabilityFlag" ]
Parameters:
Ami:
Description: "Base AMI"
Type: "AWS::EC2::Image::Id"
EnvironmentName:
Description: "The environment name"
Type: "String"
HighAvailabilityFlag:
Description: "Flag used to set the minimum and maximum size of the Auto Scaling Group"
Default: false
Type: "String"
AllowedValues: [ "true", "false" ]
KeyPairName:
Description: "Name of EC2 key pair for logging in to the instances"
Type: "String"
SecurityGroupIds:
Description: "The IDs of security groups that are permitted access to EC2 instances"
Type: "String"
Subnets:
Description: "Subnets to associate with the ASG"
Type: "List<AWS::EC2::Subnet::Id>"
VersionToDeploy:
Description: "Version to deploy"
Type: "String"
VpcId:
Description: "The ID of the VPC"
Type: "AWS::EC2::VPC::Id"
Mappings:
HighAvailability:
MinSize:
"false": 1
"true": 2
MaxSize:
"false": 1
"true": 4
Resources:
InstanceProfile:
Properties:
Path: "/"
Roles:
- !Ref "InstanceRole"
Type: "AWS::IAM::InstanceProfile"
InstanceRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: "Allow"
Principal:
Service:
- ec2.amazonaws.com
Version: "2012-10-17"
Path: "/"
Type: "AWS::IAM::Role"
Policy:
Properties:
PolicyDocument:
Statement:
- Action:
- cloudformation:DescribeStacks
- ec2:Describe*
Effect: "Allow"
Resource: "*"
Version: "2012-10-17"
PolicyName: "Service"
Roles:
- !Ref "InstanceRole"
Type: "AWS::IAM::Policy"
AutoScalingGroup:
Properties:
HealthCheckGracePeriod: 300
MetricsCollection:
- Granularity: "1Minute"
HealthCheckType: "ELB"
LaunchConfigurationName: !Ref "LaunchConfiguration"
MaxSize: !FindInMap [ "HighAvailability", "MaxSize", !Ref "HighAvailabilityFlag" ]
MinSize: !FindInMap [ "HighAvailability", "MinSize", !Ref "HighAvailabilityFlag" ]
VPCZoneIdentifier: !Ref "Subnets"
CreationPolicy:
ResourceSignal:
Count: !FindInMap [ "HighAvailability", "MinSize", !Ref "HighAvailabilityFlag" ]
Timeout: "PT5M"
UpdatePolicy:
AutoScalingRollingUpdate:
MinInstancesInService: !FindInMap [ "HighAvailability", "MinSize", !Ref "HighAvailabilityFlag" ]
PauseTime: "PT5M"
WaitOnResourceSignals: true
Type: "AWS::AutoScaling::AutoScalingGroup"
LaunchConfiguration:
Properties:
AssociatePublicIpAddress: true
IamInstanceProfile: !Ref "InstanceProfile"
ImageId: !Ref "Ami"
InstanceType: "t2.micro"
KeyName: !Ref "KeyPairName"
SecurityGroups: !Split [ ",", !Join [ ",", [ !Ref "SecurityGroupIds" ] ] ]
UserData:
Fn::Base64:
cfn-init.exe -v -s "AWS::StackName" --region "AWS::Region"
cfn-signal.exe -e 0 !Ref "WindowsServerWaitHandle"
Type: "AWS::AutoScaling::LaunchConfiguration"
WindowsServerWaitHandle:
Type: "AWS::CloudFormation::WaitConditionHandle"
WindowsServerWaitCondition:
DependsOn: "AutoScalingGroup"
Properties:
Handle: !Ref "WindowsServerWaitHandle"
Timeout: "1800"
Count: 0
Type: "AWS::CloudFormation::WaitCondition"
创建EC2实例后,我看到生成了几个日志文件:
UserdataExecution.log
2017/03/05 05:54:47Z: Userdata execution begins
2017/03/05 05:54:47Z: Zero or more than one <persist> tag was not provided
2017/03/05 05:54:47Z: Unregistering the persist scheduled task
2017/03/05 05:54:50Z: Zero or more than one <runAsLocalSystem> tag was not provided
2017/03/05 05:54:50Z: Zero or more than one <script> tag was not provided
2017/03/05 05:54:50Z: Zero or more than one <powershell> tag was not provided
2017/03/05 05:54:50Z: Zero or more than one <powershellArguments> tag was not provided
2017/03/05 05:54:50Z: Userdata execution done
WindowsIsReadyToConsole.log
2017/03/03 04:46:27Z: Sending "Windows is Ready" message to console is scheduled successfully
2017/03/05 05:54:27Z: Sending windows is ready message started
2017/03/05 05:54:28Z: Opening COM port handle to write to the console
2017/03/05 05:54:30Z: Serial Port in use. Waiting for Serial Port...
2017/03/05 05:54:48Z: Message: Windows is Ready to use
2017/03/05 05:54:48Z: Sending windows is ready message done
答案 0 :(得分:3)
<强> TLDR 强>
这是EC2无法向ASG发送成功信号时发生的一般性错误。可能出现这种情况的原因有很多种,但很可能无论您使用哪种健康检查都无法按预期工作。
使用下面的userData应该对运行状况检查进行硬编码,这是开始测试应用程序和Cloud Formation模板的好方法。
我的问题
我删除了对Sub CreateProcesSectList()
'Create worksheet "ProcessSectionsList" if it doesn't exist. And then Create a Process Sections Pivot Table
Dim Baslik1, Baslik2, Baslik3, Baslik4, Baslik5 As String
Baslik1 = Sheet5.Range("F2").Value 'Items' Descriptions
Baslik2 = Sheet5.Range("H2").Value 'Process Sections
Baslik3 = Sheet5.Range("I2").Value 'Quantity
Baslik4 = Sheet5.Range("K2").Value 'Unit cost
Baslik5 = Sheet5.Range("M2").Value 'Total Cost
Application.ScreenUpdating = False
CreateSheetIf ("ProcessSectionsList")
Sheets("ProcessSectionsList").Select
Columns("A:AK").Select
Range("A1").Activate
Selection.Delete Shift:=xlToLeft
Sheet5.Select
Application.Goto Reference:="R100000C6"
Selection.End(xlUp).Select
ActiveCell.CurrentRegion.Select
Set tblo = ActiveCell.CurrentRegion
tblo.Offset(1, 0).Resize(tblo.Rows.Count - 1, _
tblo.Columns.Count).Select
'Sheet5.Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"R2C2:R388C22", Version:=xlPivotTableVersion14).CreatePivotTable _
TableDestination:="ProcessSectionsList!R1:R1048576", TableName:="ProcessSectionsPivotTable", _
DefaultVersion:=xlPivotTableVersion14
Range("a1").Select
Sheets("ProcessSectionsList").Select
Cells(1, 1).Select
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik2)
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik1)
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik3)
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik4)
.Orientation = xlRowField
.Position = 4
End With
ActiveSheet.PivotTables("ProcessSectionsPivotTable").AddDataField ActiveSheet.PivotTables( _
"ProcessSectionsPivotTable").PivotFields(Baslik5), "Count of Total Cost", xlCount
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik2)
.LayoutForm = xlTabular
.RepeatLabels = True
End With
ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik1). _
Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik1)
.LayoutForm = xlTabular
.RepeatLabels = True
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik3)
.LayoutForm = xlTabular
.RepeatLabels = True
.Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik4)
.LayoutForm = xlTabular
.RepeatLabels = True
.Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
End With
Range("C223").Select
ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields("Count of Total Cost"). _
Function = xlSum
Range("A1").Select
With ActiveSheet.PivotTables("ProcessSectionsPivotTable").PivotFields(Baslik2)
.PivotFilters.Add Type:=xlCaptionDoesNotBeginWith, Value1:="0"
.PivotItems("(blank)").Visible = False
End With
With ActiveSheet.PivotTables("ProcessSectionsPivotTable")
.TableStyle2 = "PivotStyleLight20"
.ShowDrillIndicators = False
End With
Range("a1").Select
ActiveSheet.PivotTables("ProcessSectionsPivotTable").CompactLayoutRowHeader = Baslik2
Columns("d:e").Select
Selection.Style = "Currency"
Columns("B:B").ColumnWidth = 54.14
Range("a1").Select
ActiveWindow.ScrollRow = 1
Application.ScreenUpdating = True
End Sub
和AWS::CloudFormation::WaitConditionHandle
我的AWS::CloudFormation::WaitCondition
脚本存在问题:
UserData
个标记<script>
)结果是:
${AWS::StackName}
答案 1 :(得分:1)
您错过了IAM角色- cloudformation:SignalResource
中的PolicyDocument
操作。发送信号需要此权限。