【问题标题】:AWS Cloudformation Random Build FailAWS Cloudformation 随机构建失败
【发布时间】:2018-07-25 04:09:21
【问题描述】:

我正在使用 Cloudformation 来自动创建实例。我正在使用自动缩放组来根据我的需要构建一个可变数量。但是,当我从该脚本构建 2 个以上实例时,至少有 1 个实例无法运行。

例如:我声明 7 个实例供 cloudformation 构建,6 个可以完美运行,但总有 1 个无法运行。没有错误,它似乎只是忽略了命令。在此脚本的 userdata 部分中,我启动 docker 以在实例中运行。

我收到此错误:rpc error code = 13 desc = transport is closing

有人可以看看是不是做错了什么或者我错过了一步吗?

     {
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Test",
    "Parameters": {
        "InstanceType": {
            "Type": "String",
            "Default": "t2.large"
        },

        "NoOfInstances": {
            "Type": "String",
            "ConstraintDescription": ""
        },

        "RoleName": {
            "Type": "String",
            "Default": "**",
            "ConstraintDescription": ""
        },

        "VPCParameter": {
            "Type": "AWS::EC2::VPC::Id",
            "Default": "**"
        },

        "SubnetsParameter": {
            "Type": "List<AWS::EC2::Subnet::Id>",
            "Default": "**"
        },

        "KeyName": {
            "Type": "AWS::EC2::KeyPair::KeyName",
            "Default": "**",
            "ConstraintDescription": ""
        }
    },

    "Mappings": {
        "AWSInstanceType2Arch": {
            "t2.large": {
                "Arch": "HVM64"
            }
        },

        "AWSRegionArch2AMI": {
            "**": {
                "HVM64": "**"
            }
        }
    },

    "Resources": {

        "LaunchConfig": {
            "Type": "AWS::AutoScaling::LaunchConfiguration",
            "Properties": {
                "KeyName": {
                    "Ref": "KeyName"
                },
                "IamInstanceProfile": {
                    "Ref": "RoleName"
                },
                "SecurityGroups": [{
                    "Ref": "WebServerSecurityGroup"
                }],
                "ImageId": {
                    "Fn::FindInMap": ["AWSRegionArch2AMI",
                        {
                            "Ref": "AWS::Region"
                        }, {
                            "Fn::FindInMap": ["AWSInstanceType2Arch", {
                                "Ref": "InstanceType"
                            }, "Arch"]
                        }
                    ]
                },

                "InstanceType": {
                    "Ref": "InstanceType"
                },
                "UserData": {
                    "Fn::Base64": {
                        "Fn::Join": ["", [ ** ]]
                    }
                }
            }
        },

        "AutoScalingServerGroup": {
            "Type": "AWS::AutoScaling::AutoScalingGroup",

            "Properties": {
                "LaunchConfigurationName": {
                    "Ref": "LaunchConfig"
                },
                "MinSize": "1",
                "MaxSize": "30",
                "Cooldown": "300",
                "VPCZoneIdentifier": {
                    "Ref": "SubnetsParameter"
                },
                "DesiredCapacity": {
                    "Ref": "NoOfInstances"
                },
                "Tags": [ ** ]
            }
        },

        "WebServerSecurityGroup": {
            "Type": "AWS::EC2::SecurityGroup",
            "Properties": {
                "GroupDescription": "**",
                "VpcId": {
                    "Ref": "VPCParameter"
                },
                "SecurityGroupIngress": [{
                    "IpProtocol": "tcp",
                    "CidrIp": "**",
                    "FromPort": "**",
                    "ToPort": "**"
                }, ]
            }
        },

        "WebServerScaleUpPolicy": {
            "Type": "AWS::AutoScaling::ScalingPolicy",
            "Properties": {
                "AdjustmentType": "ChangeInCapacity",
                "AutoScalingGroupName": {
                    "Ref": "AutoScalingServerGroup"
                },
                "Cooldown": "60",
                "ScalingAdjustment": "1"
            }
        },

        "WebServerScaleDownPolicy": {
            "Type": "AWS::AutoScaling::ScalingPolicy",
            "Properties": {
                "AdjustmentType": "ChangeInCapacity",
                "AutoScalingGroupName": {
                    "Ref": "AutoScalingServerGroup"
                },
                "Cooldown": "60",
                "ScalingAdjustment": "-1"
            }
        }
    }
  }

【问题讨论】:

    标签: amazon-web-services docker amazon-ec2 amazon-cloudformation


    【解决方案1】:

    您可能会达到 EC2 实例限制 - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html

    您还可以查看 Auto Scaling 组的 活动历史记录 选项卡。看看有没有有用的信息。

    【讨论】:

    • 我在高容量时有限制,并且活动历史选项卡没有问题。
    猜你喜欢
    • 2017-04-10
    • 2020-08-25
    • 2014-04-16
    • 2020-05-12
    • 2014-05-29
    • 2021-06-29
    • 2020-10-23
    • 2017-10-18
    • 2018-10-12
    相关资源
    最近更新 更多