brikis98 / terraform-up-and-running-code

Code samples for the book "Terraform: Up & Running" by Yevgeniy Brikman
http://www.terraformupandrunning.com/
MIT License
2.87k stars 1.92k forks source link

Cannot connect to web server from chapter 2 #55

Closed vim-diesel closed 4 years ago

vim-diesel commented 4 years ago

curl fails to work like in the book

provider "aws" {
    version = "~> 2.0"
    region = "us-east-1"
}

resource "aws_instance" "example" {
    ami                     = "ami-0fc61db8544a617ed"
    instance_type           = "t2.micro" 
    vpc_security_group_ids  = [aws_security_group.inst.id]

    user_data = <<-EOF
                #!/bin/bash
                echo "Hello, world" > index.html
                nohup busybox https -f -p 8080 &
                EOF
}

resource "aws_security_group" "inst" {
    name = "terra_inst"
    ingress {
        from_port   = 8080
        to_port     = 8080
        protocol    = "tcp"
        cidr_blocks =["0.0.0.0/0"]
    }
}
curl http://54.152.181.11:8080
curl: (7) Failed to connect to 54.152.181.11 port 8080: Connection refused
vim-diesel commented 4 years ago

Turns out this AMI is for Amazon Linux 2. Where do I find the amis? Book fails to mention this.