Cloudformation ValidationError:堆栈(堆栈名称)处于CREATE_COMPLETE状态,无法发出信号

Sam*_*ner 3 aws-cloudformation

我创建了一个aws Cloudformation脚本,它启动了,但是当我查看日志时,它显示以下错误:

ValidationError:堆栈stackarn处于CREATE_COMPLETE状态,无法发出信号

我查看了有关此错误的其他帖子,这些帖子表明问题出在实例ID是从第一个实例或自动伸缩组派生的,而该ID没有设置所需的容量,这对我都不适用。

这是我的云形成模板

{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
    "AWS::CloudFormation::Designer": {
        "90d29d54-61c0-4b64-8f16-bab58c2da737": {
            "size": {
                "width": 510,
                "height": 330
            },
            "position": {
                "x": 650,
                "y": 200
            },
            "z": 0,
            "embeds": [
                "9da7a6f1-462f-45c1-bc0c-10fe6a297ea0",
                "791e1b81-a4ed-4b9a-a1b6-e37f92201579",
                "d4706141-a8d6-4d08-b092-cabedf2d351f",
                "25f02a3f-31da-4e2a-8a3b-31cc9c860451"
            ]
        },
        "25f02a3f-31da-4e2a-8a3b-31cc9c860451": {
            "size": {
                "width": 250,
                "height": 110
            },
            "position": {
                "x": 850,
                "y": 250
            },
            "z": 1,
            "parent": "90d29d54-61c0-4b64-8f16-bab58c2da737",
            "embeds": [
                "9eb6713b-7a7f-46a2-8a53-76738c2069e7",
                "ee1affdf-e6fe-453f-b754-cf2de003f1d8",
                "e8849c27-1095-4667-906a-6f194c39e5bb"
            ]
        },
        "791e1b81-a4ed-4b9a-a1b6-e37f92201579": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 940,
                "y": 450
            },
            "z": 1,
            "parent": "90d29d54-61c0-4b64-8f16-bab58c2da737",
            "embeds": []
        },
        "11d6e6db-f8bf-4162-83f4-3b4cdd3ecd9c": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 280,
                "y": 340
            },
            "z": 0,
            "embeds": []
        },
        "75f9474e-7e06-4879-8e2e-42f9063117bf": {
            "source": {
                "id": "90d29d54-61c0-4b64-8f16-bab58c2da737"
            },
            "target": {
                "id": "11d6e6db-f8bf-4162-83f4-3b4cdd3ecd9c"
            },
            "z": 0
        },
        "9da7a6f1-462f-45c1-bc0c-10fe6a297ea0": {
            "size": {
                "width": 120,
                "height": 120
            },
            "position": {
                "x": 700,
                "y": 270
            },
            "z": 1,
            "parent": "90d29d54-61c0-4b64-8f16-bab58c2da737",
            "embeds": [
                "93a62438-214b-4c30-906d-c45d73f0a288"
            ]
        },
        "93a62438-214b-4c30-906d-c45d73f0a288": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 730,
                "y": 310
            },
            "z": 2,
            "parent": "9da7a6f1-462f-45c1-bc0c-10fe6a297ea0",
            "embeds": [],
            "isassociatedwith": [
                "11d6e6db-f8bf-4162-83f4-3b4cdd3ecd9c"
            ]
            "dependson": [
                "75f9474e-7e06-4879-8e2e-42f9063117bf"
            ]
        },
        "e9956922-4cfe-4d1a-a4c9-814613d2517e": {
            "source": {
                "id": "9da7a6f1-462f-45c1-bc0c-10fe6a297ea0"
            },
            "target": {
                "id": "25f02a3f-31da-4e2a-8a3b-31cc9c860451"
            },
            "z": 1
        },
        "e8849c27-1095-4667-906a-6f194c39e5bb": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 870,
                "y": 280
            },
            "z": 2,
            "parent": "25f02a3f-31da-4e2a-8a3b-31cc9c860451",
            "embeds": [],
            "isassociatedwith": [
                "ee1affdf-e6fe-453f-b754-cf2de003f1d8",
                "9eb6713b-7a7f-46a2-8a53-76738c2069e7"
            ]
            "dependson": [
                "93a62438-214b-4c30-906d-c45d73f0a288"
            ]
        },
        "9eb6713b-7a7f-46a2-8a53-76738c2069e7": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 940,
                "y": 280
            },
            "z": 2,
            "parent": "25f02a3f-31da-4e2a-8a3b-31cc9c860451",
            "embeds": [],
            "isassociatedwith": [
                "d4706141-a8d6-4d08-b092-cabedf2d351f"
            ]
        },
        "ee1affdf-e6fe-453f-b754-cf2de003f1d8": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 1020,
                "y": 280
            },
            "z": 2,
            "parent": "25f02a3f-31da-4e2a-8a3b-31cc9c860451",
            "embeds": [],
            "isassociatedwith": [
                "791e1b81-a4ed-4b9a-a1b6-e37f92201579"
            ]
        },
        "d4706141-a8d6-4d08-b092-cabedf2d351f": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 802.9767066348955,
                "y": 452.6381721949601
            },
            "z": 1,
            "parent": "90d29d54-61c0-4b64-8f16-bab58c2da737",
            "embeds": []

        },
        "f2021951-c570-4233-8ccd-a05be043632c": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 1260,
                "y": 210
            },
            "z": 0,
            "embeds": []
        },
        "c892fb7e-40c0-4391-be11-3e005ed16251": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 1370,
                "y": 210
            },
            "z": 0,
            "embeds": []
        },
        "582ee47a-34d2-4faa-956f-72bbe48b5ca1": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 1260,
                "y": 340
            },
            "z": 0,
            "embeds": []
        },
        "68ddbe84-8848-4920-8700-df090e65d755": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 1370,
                "y": 340
            },
            "z": 0,
            "embeds": []
        }
    }
},
"Resources": {
    "VPC": {
        "Type": "AWS::EC2::VPC",
        "Properties": {
            "EnableDnsSupport": "true",
            "EnableDnsHostnames": "true",
            "CidrBlock": "10.0.0.0/16"
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "90d29d54-61c0-4b64-8f16-bab58c2da737"
            }
        }
    },
    "PublicSubnet": {
        "Type": "AWS::EC2::Subnet",
        "Properties": {
            "VpcId": {
                "Ref": "VPC"
            },
            "CidrBlock": "10.0.0.0/24"
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "25f02a3f-31da-4e2a-8a3b-31cc9c860451"
            }
        }
    },
    "PublicLoadBalancerSecurityGroup": {
        "Type": "AWS::EC2::SecurityGroup",
        "Properties": {
            "GroupDescription": "Public Elastic Load Balancing security group with HTTP access on port 80 from the Internet",
            "SecurityGroupIngress": [
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "CidrIp": "0.0.0.0/0"
                }
            ],
            "SecurityGroupEgress": [
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "CidrIp": "0.0.0.0/0"
                }
            ],
            "VpcId": {
                "Ref": "VPC"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "791e1b81-a4ed-4b9a-a1b6-e37f92201579"
            }
        }
    },
    "InternetGateway": {
        "Type": "AWS::EC2::InternetGateway",
        "Properties": {},
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "11d6e6db-f8bf-4162-83f4-3b4cdd3ecd9c"
            }
        }
    },
    "EC2VPCG4YNHI": {
        "Type": "AWS::EC2::VPCGatewayAttachment",
        "Properties": {
            "VpcId": {
                "Ref": "VPC"
            },
            "InternetGatewayId": {
                "Ref": "InternetGateway"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "75f9474e-7e06-4879-8e2e-42f9063117bf"
            }
        }
    },
    "PublicRouteTable": {
        "Type": "AWS::EC2::RouteTable",
        "Properties": {
            "VpcId": {
                "Ref": "VPC"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "9da7a6f1-462f-45c1-bc0c-10fe6a297ea0"
            }
        }
    },
    "PublicRoute": {
        "Type": "AWS::EC2::Route",
        "Properties": {
            "DestinationCidrBlock": "0.0.0.0/0",
            "RouteTableId": {
                "Ref": "PublicRouteTable"
            },
            "GatewayId": {
                "Ref": "InternetGateway"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "93a62438-214b-4c30-906d-c45d73f0a288"
            }
        },
        "DependsOn": [
            "EC2VPCG4YNHI"
        ]
    },
    "EC2SRTA188EJ": {
        "Type": "AWS::EC2::SubnetRouteTableAssociation",
        "Properties": {
            "RouteTableId": {
                "Ref": "PublicRouteTable"
            },
            "SubnetId": {
                "Ref": "PublicSubnet"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "e9956922-4cfe-4d1a-a4c9-814613d2517e"
            }
        }
    },
    "WebServerFleet": {
        "Type": "AWS::AutoScaling::AutoScalingGroup",
        "Properties": {
            "MinSize": "1",
            "MaxSize": "10",
            "DesiredCapacity": {
                "Ref": "WebServerCount"
            },
            "VPCZoneIdentifier": [
                {
                    "Ref": "PublicSubnet"
                }
            ],
            "LoadBalancerNames": [
                {
                    "Ref": "PublicElasticLoadBalancer"
                }
            ],
            "LaunchConfigurationName": {
                "Ref": "WebServerLaunchConfig"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "e8849c27-1095-4667-906a-6f194c39e5bb"
            }
        },
        "DependsOn": [
            "PublicRoute"
        ]
    },
    "WebServerLaunchConfig": {
        "Type": "AWS::AutoScaling::LaunchConfiguration",
        "Properties": {
            "InstanceType": {
                "Ref": "InstanceType"
            },
            "ImageId": {
                "Fn::FindInMap": [
                    "AWSRegionArch2AMI",
                    {
                        "Ref": "AWS::Region"
                    },
                    {
                        "Fn::FindInMap": [
                            "AWSInstanceType2Arch",
                            {
                                "Ref": "InstanceType"
                            },
                            "Arch"
                        ]
                    }
                ]
            },
            "KeyName": {
                "Ref": "KeyName"
            },
            "AssociatePublicIpAddress": "true",
            "UserData": {
                "Fn::Base64": {
                    "Fn::Join": [
                        "",
                        [
                            "#!/bin/bash -xe\n",
                            "yum install -y aws-cfn-bootstrap\n",
                            "# Install the files and packages from the metadata\n",
                            "/opt/aws/bin/cfn-init -v ",
                            "         --stack ",
                            {
                                "Ref": "AWS::StackName"
                            },
                            "         --resource WebServerLaunchConfig ",
                            "         --configsets All ",
                            "         --region ",
                            {
                                "Ref": "AWS::Region"
                            },
                            "\n",
                            "#Install Redis\n",
                            "#rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm\n",
                            "rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm\n",
                            "yum --enablerepo=remi,remi-test -y install redis\n",
                            "chkconfig --add redis\n",
                            "chkconfig --level 345 redis on\n",
                            "service redis start\n",
                            "# Clone GitHub Repository\n",
                            "git clone -b master https://",
                            {
                                "Ref": "GitHubUsername"
                            },
                            ":",
                            {
                                "Ref": "GitHubPassword"
                            },
                            "@github.com/repo /var/www/html\n",
                            "# Update the httpd.conf file and restart the web server\n",
                            "mv -f /var/www/html/resources/conf/httpd.conf /etc/httpd/conf/httpd.conf \n",
                            "service httpd restart\n",
                            "# Install Composer\n",
                            "#chmod 755 -R /usr/local/bin\n",
                            "curl -sS https://getcomposer.org/installer > /tmp/installer\n",
                            "COMPOSER_HOME=/usr/local/composer php < /tmp/installer\n",
                            "mv composer.phar /usr/local/bin/composer.phar \n",
                            "groupadd www\n",
                            "usermod -a -G www ec2-user\n",
                            "usermod -a -G www apache\n",
                            "chown -R root:www /var/www\n",
                            "find /var/www -type d -exec chmod 2775 {} +\n",
                            "find /var/www -type f -exec chmod 0664 {} +\n",
                            "COMPOSER_HOME=/usr/local/composer /usr/local/bin/composer.phar install -d /var/www/html --no-plugins --no-scripts\n",
                            "mkdir /var/www/html/storage/framework\n",
                            "mkdir /var/www/html/storage/framework/views\n",
                            "mkdir /var/www/html/storage/framework/sessions\n",
                            "chmod -R 775 /var/www/html/storage\n",
                            "# Signal the status from cfn-init\n",
                            "/opt/aws/bin/cfn-signal -e $? ",
                            "         --stack ",
                            {
                                "Ref": "AWS::StackName"
                            },
                            "         --resource WebServerFleet ",
                            "         --region ",
                            {
                                "Ref": "AWS::Region"
                            },
                            "\n"
                        ]
                    ]
                }
            },
            "SecurityGroups": [
                {
                    "Ref": "WebServerSecurityGroup"
                }
            ]
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "9eb6713b-7a7f-46a2-8a53-76738c2069e7"
            },
            "AWS::CloudFormation::Init": {
                "configSets": {
                    "All": [
                        "installWebDependencies"
                    ]
                },
                "installWebDependencies": {
                    "packages": {
                        "yum": {
                            "httpd24": [],
                            "php56": [],
                            "php56-pdo": [],
                            "php56-mbstring": [],
                            "php56-mcrypt": [],
                            "php-ZendFramework-Db-Adapter-Pdo-Mysql.noarch": [],
                            "git": []
                        }
                    },
                    "services": {
                        "sysvinit": {
                            "httpd": {
                                "enabled": "true",
                                "ensureRunning": "true"
                            }
                        }
                    }
                }
            }
        }
    },
    "PublicElasticLoadBalancer": {
        "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
        "Properties": {
            "Listeners": [
                {
                    "LoadBalancerPort": "80",
                    "InstancePort": "80",
                    "Protocol": "HTTP"
                }
            ],
            "HealthCheck": {
                "Target": "HTTP:80/",
                "HealthyThreshold": "3",
                "UnhealthyThreshold": "5",
                "Interval": "90",
                "Timeout": "60"
            },
            "Subnets": [
                {
                    "Ref": "PublicSubnet"
                }
            ],
            "SecurityGroups": [
                {
                    "Ref": "PublicLoadBalancerSecurityGroup"
                }
            ]
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "ee1affdf-e6fe-453f-b754-cf2de003f1d8"
            }
        }
    },
    "WebServerSecurityGroup": {
        "Type": "AWS::EC2::SecurityGroup",
        "Properties": {
            "GroupDescription": "Allow access from load balancer and SSH traffic",
            "SecurityGroupIngress": [
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "SourceSecurityGroupId": {
                        "Ref": "PublicLoadBalancerSecurityGroup"
                    }
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "22",
                    "ToPort": "22",
                    "CidrIp": {
                        "Ref": "SSHLocation"
                    }
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "CidrIp": "31.221.88.186/32"
                }
            ],
            "VpcId": {
                "Ref": "VPC"
            }
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "d4706141-a8d6-4d08-b092-cabedf2d351f"
            }
        }
    },
    "AnvilQueue": {
        "Type": "AWS::SQS::Queue",
        "Properties": {
            "QueueName": "phonehome-incident-anvil",
            "DelaySeconds": 0,
            "ReceiveMessageWaitTimeSeconds": 0,
            "VisibilityTimeout": 30,
            "MessageRetentionPeriod": 1209600
        },
        "Metadata": {
            "AWS::CloudFormation::Designer": {
                "id": "f202195

kic*_*hik 5

似乎您没有在等待自动伸缩组,因此在ASG具有任何工作实例之前,堆栈创建已完成。在实例启动并执行时cfn-signal,堆栈已完成。

尝试添加CreationPolicy

https://aws.amazon.com/blogs/devops/use-a-creationpolicy-to-wait-for-on-instance-configurations/

和/或UpdatePolicy

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html

根据您的情况的具体情况,如下所示:

"WebServerFleet": {
  "CreationPolicy": {
    "ResourceSignal": {
      "Timeout": "PT15M",
      "Count": "1"
    }
  },
  "UpdatePolicy": {
    "AutoScalingScheduledAction": {
      "IgnoreUnmodifiedGroupSizeProperties": "true"
    },
    "AutoScalingRollingUpdate": {
      "MinInstancesInService": "1",
      "MaxBatchSize": "2",
      "WaitOnResourceSignals": "true",
      "PauseTime": "PT15M"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

如果您的设置更长或更短,则可能需要调整超时。批次大小也是要考虑的因素。