title: timeout ConnectionError error while downloading package from s3 bucket on ec2: aws
body: <p>I am trying to create a test EC2 instance and download an initial package from S3 Bucket via Cloud formation Script but I am getting below error while using.</p>
  
  <pre><code>cfn-init
  </code></pre>
  
  <p>Does my instance need internet connection to execute cfn-init?</p>
  
  <p>"2018-04-03 01:23:29,660 [ERROR] ConnectionError
  Traceback (most recent call last):
    File "cfnbootstrap\util.pyc", line 162, in _retry
    File "cfnbootstrap\util.pyc", line 234, in _timeout
  ConnectionError: ('Connection aborted.', error(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))"</p>
  
  <p>Below is the template i am using to create the instance and download the package. Instance creation is successful and I am able to RDP the instance but no luck with package download.</p>
  
  <pre><code>{
  "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" : ["", [
                        "&lt;script&gt;\n",
                          "cfn-init.exe -s ", 
                          {"Ref" : "AWS::StackId"}, 
                          " -r RetailWebServer --region ", 
                          {"Ref" : "AWS::Region"},
                          " --http-proxy http://proxy.aws.xxxxxx.local:8080 \n",
                      "&lt;/script&gt;\n"
                      ]]
                  }
              }
          }
  
      }   
  }
  </code></pre>
  
  <p>}</p>