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

Issue getting first proof of concept running #61

Closed phyzical closed 4 years ago

phyzical commented 4 years ago

Hey there,

Running though the book as my new gig is running terraform but i seem to be running into an issue with the initial busybox webserver,

its not a huge deal as i get what its meant to do, but figured id mention it as its the first example that may deter devs that have a less exp from going further thinking they may have done something wrong

attached is what i came up with incase its something silly on my part

provider "aws" {
  region = "us-east-2"
}

resource "aws_instance" "example1" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  tags = {
    Name = "example1"
  }

  vpc_security_group_ids = [aws_security_group.example1_instance.id]
  key_name               = "phyzical-ssh-key"
  user_data              = <<-EOF
                            #!/bin/bash
                            echo "Hello, World" > index.html
                            nohup busybox http -f -p 8080 &
                            EOF
}

resource "aws_security_group" "example1_instance" {
  name = "example1-instance"

  ingress {
    from_port   = 8080
    to_port     = 8080
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["123.123.123.123/32"]
  }
}

resource "aws_key_pair" "phyzical-ssh-key" {
  key_name   = "phyzical-ssh-key"
  public_key = file("~/.ssh/id_rsa.pub")
}

output "instance_ip" {
  description = "The public ip for ssh access"
  value       = aws_instance.example1.public_ip
}

if i jump on the server that is initialized and try to manually start busybox i get the following;

sudo busybox http -f -p 8080

http: applet not found

my google fu suggests its PATH issues/ compile issues with the image itself. but i could not succeed and have decided just progress further on in the book

phyzical commented 4 years ago

lol.. nvm sorry. its httpd not http