从ec2:aws上的s3存储桶下载软件包时出现超时ConnectionError错误

时间:2018-04-03 01:58:49

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

我正在尝试创建一个测试EC2实例,并通过Cloud Formation脚本从S3 Bucket下载一个初始包,但是在使用时我收到了以下错误。

cfn-init

我的实例是否需要互联网连接来执行cfn-init?

" 2018-04-03 01:23:29,660 [错误] ConnectionError Traceback(最近一次调用最后一次):   文件" cfnbootstrap \ util.pyc",第162行,在_retry中   文件" cfnbootstrap \ util.pyc",第234行,在_timeout中 ConnectionError :('连接已中止。',错误(10060,'连接尝试失败,因为连接方在一段时间后未正确响应,或已建立的连接因连接主机发生故障而失败)回应')"

下面是我用来创建实例并下载包的模板。实例创建是成功的,我能够RDP实例,但没有运气包下载。

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "Test Stack",

    "Parameters" : {
      "SubnetId" : {
          "Description" : "Subnets Id for EC2 instances.",
          "Type" : "String",
          "AllowedValues" : [ "xxxxxx"]
      },
      "KeyName" : {
          "Description" : "The EC2 Key Pair to create Windows instance",
          "Type" : "AWS::EC2::KeyPair::KeyName",
          "ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
      },
      "WebInstanceType" : {
          "Description" : "WebServer EC2 instance type",
          "Type" : "String",
          "Default" : "t2.micro",
          "AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"],
          "ConstraintDescription" : "must be a valid EC2 instance type."
      },
      "WebImageId" : {
          "Description" : "Id of the AMI to be loaded on the EC2 instance for webserver",
          "Type" : "String"
      }
  },

  "Resources": {
      "WebServer": {
          "Type" : "AWS::EC2::Instance",
          "Metadata": {
              "AWS::CloudFormation::Authentication": {
                  "S3AccessCreds": {
                      "type": "S3",
                      "roleName": "InstanceRole",
                      "buckets" : ["test-bucket"]
                  }
              },
              "AWS::CloudFormation::Init": {
                  "config": {
                      "sources": {
                          "c:\\S3\\SSMS": "https://s3-ap-southeast-2.amazonaws.com/test-bucket/test.zip"
                      }
                  }
              }
          },

          "Properties" : {
              "IamInstanceProfile" : "xxxxxxx",
              "InstanceInitiatedShutdownBehavior" : "stop",
              "KeyName" : { "Ref" : "KeyName" },
              "InstanceType" : { "Ref" : "WebInstanceType" },
              "ImageId" : { "Ref" : "WebImageId" },
              "Tags" : [
              {  "Key" : "Name", "Value" : "test1"}
              ],
              "NetworkInterfaces" : [
              {
                  "DeviceIndex"         : "0",
                  "DeleteOnTermination" : "true",
                  "SubnetId"                : { "Ref" : "SubnetId" },
                  "GroupSet"                : [ "xxxxxxx, xxxxxxx" ]
              }],
              "UserData" : {
                  "Fn::Base64" : { 
                      "Fn::Join" : ["", [
                      "<script>\n",
                        "cfn-init.exe -s ", 
                        {"Ref" : "AWS::StackId"}, 
                        " -r RetailWebServer --region ", 
                        {"Ref" : "AWS::Region"},
                        " --http-proxy http://proxy.aws.xxxxxx.local:8080 \n",
                    "</script>\n"
                    ]]
                }
            }
        }

    }   
}

}

0 个答案:

没有答案