Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error launching source instance (dial tcp: i/o timeout) #781

Closed
sydseter opened this issue Jan 13, 2015 · 12 comments
Closed

Error launching source instance (dial tcp: i/o timeout) #781

sydseter opened this issue Jan 13, 2015 · 12 comments

Comments

@sydseter
Copy link

Not sure what I am doing wrong here. I have set up a free tier account with amazon and are using a public ubuntu 14.04 ami: ami-b83c0aa5 on a t2.micro

I get no repported errors running:

terraform -v
# Terraform v0.3.6
terraform remote -name=johansyd/private
# Remote configuration updated

terraform plan

aws_instance.web: Creating...
  ami:               "" => "ami-b83c0aa5"
  availability_zone: "" => "<computed>"
  block_device.#:    "" => "<computed>"
  instance_type:     "" => "t2.micro"
  key_name:          "" => "<computed>"
  private_dns:       "" => "<computed>"
  private_ip:        "" => "<computed>"
  public_dns:        "" => "<computed>"
  public_ip:         "" => "<computed>"
  security_groups.#: "" => "<computed>"
  subnet_id:         "" => "<computed>"
  tenancy:           "" => "<computed>"

, but when I try to apply:

terraform apply
Error applying plan:
1 error(s) occurred:
* Error launching source instance: Get https://ec2.eu-central-1.amazonaws.com/?AWSAccessKeyId=KEY&Action=RunInstances&ClientToken=TOKEN&ImageId=ami-b83c0aa5&InstanceType=t2.micro&MaxCount=1&MinCount=1&Signature=sK5mZFByFRsde5OQ6MDyJ3mRh7rc4xadumlFQc9aokA%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2015-01-13T13%3A54%3A49Z&UserData=&Version=2014-06-15: dial tcp: i/o timeout

the tf is very straight forward with no dependencies.
NB: Had to remove the real keys of course.

provider "atlas" {
    token = "amazon-ubuntu-free-deploy:**byxw" 
}
provider "aws" {
    access_key = "Access Key ID"
    secret_key = "Secret Access Key"
    region = "eu-central-1" # Frankfurt
}
resource "aws_instance" "web" {
    instance_type = "t2.micro"
    ami = "ami-b83c0aa5" # ubuntu 14.04 public amazon image
}
@sydseter
Copy link
Author

I am able to push with the same keys using packer. images are built just fine as long as I am using region eu-west-1.

I tried to change into using eu-west-1 for terraform, but the result is the same. I get the same error.

provider "atlas" {
    token = "amazon-ubuntu-free-deploy:**byxw" 
}
provider "aws" {
    access_key = "Access Key ID"
    secret_key = "Secret Access Key"
    region = "eu-central-1" # Frankfurt
}
resource "aws_instance" "web" {
    instance_type = "t2.micro"
    ami = "ami-f0b11187" # ubuntu 14.04 public amazon image
}

I changed the public ami for one I maneged to build with packer, but no result. ami: ami-1f931268

@sydseter
Copy link
Author

If I use a atlas artifact built by packer. Everything works fine:

resource "atlas_artifact" "web" {
    name = "johansyd/ubuntu-free"
    type = "aws.ami"
}

Here is the packer config:

{
    "builders": [{
        "type": "amazon-ebs",
        "access_key": "Access Key ID",
        "secret_key": "Secret Access Key",
        "region": "eu-west-1",
        "source_ami": "ami-f0b11187",
        "instance_type": "t2.micro",
        "ssh_username": "ubuntu",
        "ami_name": "ubuntu-free {{timestamp}}",
        "ami_groups": "all",
        "ami_block_device_mappings": [
          {
              "device_name": "/dev/sda1",
              "volume_type": "io1",
              "iops":"900",
              "volume_size": 30,
              "delete_on_termination": true
          }],
        "launch_block_device_mappings": [
        {
            "device_name": "/dev/sda1",
            "volume_type": "io1",
            "iops":"900",
            "volume_size": 30,
            "delete_on_termination": true
        }]
    }],
    "push": {
      "name": "johansyd/private"
    },
    "provisioners": [
    {
        "type": "shell",
        "inline": [
            "sleep 30",
            "touch success.txt"
        ]
    }],
    "post-processors": [
      {
        "type": "atlas",
        "artifact": "johansyd/ubuntu-free",
        "artifact_type": "aws.ami",
        "metadata": {
          "created_at": "{{timestamp}}"
       }
      }
    ]
}

@sydseter
Copy link
Author

correction:

I had to remove

resource "aws_instance" "web" {
   instance_type = "t2.micro"
   ami = "ami-1f931268" # ubuntu 14.04 public amazon image
}

thus, no instances gets created, but if I add this:

provider "atlas" {
    token = "amazon-ubuntu-free-deploy:**byxw" 
}
provider "aws" {
    access_key = "Access Key ID"
    secret_key = "Secret Access Key"
    region = "eu-west-1" # Irland
}
resource "atlas_artifact" "web" {
  name = "johansyd/ubuntu-free"
  type = "aws.ami"
}

resource "aws_instance" "web" {
  instance_type = "t1.micro"
  ami = "ami-1f931268"
  security_groups = ["sg-bb1a83de"]
}

Then same errors as before

security_groups = ["sg-bb1a83de"] has ports: 22,80,53 and 65535 open

Error:

atlas_artifact.web: Creation complete
aws_instance.web: Error: Error launching source instance: Get https://ec2.eu-west-1.amazonaws.com/?AWSAccessKeyId=KEY&Action=RunInstances&ClientToken=TOKEN&ImageId=ami-1f931268&InstanceType=t1.micro&MaxCount=1&MinCount=1&SecurityGroup.1=sg-bb1a83de&Signature=F11S4%2Ff8B2Lxl8lZrgRP3pmTiaPAdZZFZrtlCxc3xWg%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2015-01-13T20%3A01%3A04Z&UserData=&Version=2014-06-15: dial tcp: i/o timeout
Error applying plan:

1 error(s) occurred:

@rail
Copy link

rail commented Jan 21, 2015

I hit the same issue today with 0.3.6. If I run 0.3.5 I get the following message:

aws_instance.example: Error: Error launching source instance: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out
the request. (VPCResourceNotSpecified)

I just changed the instance type to m3.medium and it happily worked with 0.3.5. 0.3.6 still had the issue.

@jweickum
Copy link

I got the same error message doing the tutorial with 0.3.6. The url in the error would work just fine pasted to curl, but terraform apply kept failing.

Eventually I figured out that the timeout was for one of the DNS server entries I had in my resolv.conf, and not for the aws endpoint. After removing the entry, it worked fine.

This really should be handled more gracefully in the code, as everything else on my box that needs to resolve dns is able to deal with this situation just fine. At the very least, it would be nice if the error message included the endpoint that actually timed out.

@mitchellh
Copy link
Contributor

This error is coming from deep within the library we use to talk to AWS. It is a very strange error. We're in the process of switching to another AWS library (for 0.4.0), the official AWS Go library, and I hope this will resolve this issue. At the very least, it'll render it moot since this error is coming from a soon-to-be defunct library.

Thanks for the debug info, but let's close this out because of the above.

@jbarajas
Copy link

I also got this same error. In my case, it had to do with the security group. Essentially, I was working out of a coffee shop and forgot to add my CIDR block to the Security Groups. Therefore, terraform was not able to reach the machine via ssh due to Security Group restrictions.

I modified my CIDR block list variable to include the IP of my current location and had no issues.

@parmarsumit
Copy link

I got the same issue .
terraform init
Initializing modules...

  • module.pcform_rds

Initializing the backend...
Error loading state: RequestError: send request failed
caused by: Get https://tf-cs-pcform.s3.eu-west-1.amazonaws.com/?prefix=env%3A%2F: dial tcp: i/o timeout

@red8888
Copy link

red8888 commented Jun 29, 2018

Just got the same issue:

terraform --version
Terraform v0.11.7
provider.aws v1.25.0
provider.template v1.0.0

Transient error, worked on retry, but FYI

@naumannt
Copy link

naumannt commented Dec 3, 2018

I have this problem too when addressing a eks cluster I created in module 1 through the kubernetes provider in module 2. I am not sure if it's because Terraform tries to create Kubernetes resources before the cluster is fully available, but if I rerun 'terraform apply' immediately it works...

@kolly83
Copy link

kolly83 commented Aug 15, 2019

Hello

@jbarajas - What do you mean by? "add my CIDR block to the Security Groups."

I have added the 192.168.43.11 IP addr. of the bridged enp0s3 interface of the VM to the default Security Group but I've still got the i/o timeout error.

TCP: 22, 80, 443, 53, 5985, 5986, 3389, 0 - 65535
UDP: 53
All traffic | All | All default security group

[ERROR] error creating shell: unknown error Post http://52.18.42.176:5985/wsman: dial tcp 52.18.42.176:5985: i/o timeout
2019-08-15T15:18:02.696+0100 [DEBUG] plugin.terraform: file-provisioner (internal) 2019/08/15 15:18:02 [WARN] retryable error: unknown error Post http://52.18.42.176:5985/wsman: dial tcp 52.18.42.176:5985: i/o timeout

I have used this AMI: ami-9c25a6e5.

Maybe because it has EBS device?

Thank you.

@ghost
Copy link

ghost commented Aug 16, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants