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

2nd chapter code AMI does no longer exist #68

Open
aanzolaavila opened this issue Mar 29, 2021 · 9 comments
Open

2nd chapter code AMI does no longer exist #68

aanzolaavila opened this issue Mar 29, 2021 · 9 comments
Labels

Comments

@aanzolaavila
Copy link

On https://github.com/brikis98/terraform-up-and-running-code/blob/master/code/terraform/02-intro-to-terraform-syntax/webserver-cluster/main.tf, the AMI for the instances does no longer exist and fails, and I don't know what other image would contain busybox for trying out the HTTP requests

I was trying out ami-0c55b159cbfafe1f0, but it does not have busybox installed.

@brikis98
Copy link
Owner

brikis98 commented Apr 1, 2021

I'm pretty sure ami-0c55b159cbfafe1f0 still exists, but AMIs are region-specific, so that's the ID solely for the us-east-2 region. Make sure that's the region you pick!

@aanzolaavila
Copy link
Author

aanzolaavila commented Apr 5, 2021

I was using us-east-1, but I think I found a better solution for me on https://learn.hashicorp.com/tutorials/terraform/cloud-init, in which the main.tf file in the instances folder contains this config (modified a little bit by me), which will get the latest ubuntu image without having to write a specific AMI, which for me is a better solution that is independent from the region as you pointed out.

resource "aws_launch_configuration" "example" {
  image_id = data.aws_ami.ubuntu.id
  instance_type = "t2.micro"
  security_groups = [aws_security_group.instance.id, aws_security_group.ssh.id]

  user_data = data.template_file.user_data.rendered

  lifecycle { 
    create_before_destroy = true
  }
}

data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-*20*-amd64-server-*"]
  }

  filter {
    name = "virtualization-type"
    values = ["hvm"]
  }
  
  owners = ["099720109477"] # Canonical
}

@brikis98
Copy link
Owner

brikis98 commented Apr 6, 2021

Yup, keep reading, we use the aws_ami data source later in the book :)

@Mr-Slippery
Copy link

In case you are also stuck on trying the web server on a different region, this is how to find out the right AMI Id for your region. Search the given AMI Id on region us-east-2 and find the AMI Name (which might be worth mentioning in a possible future edition of the book too):
image
And then switch to the region you deploy to and use the same search interface but search for the AMI Name: ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20190212.1
Hope this helps.

@brikis98
Copy link
Owner

@DasLeo
Copy link

DasLeo commented Oct 25, 2021

I just used the latest Ubuntu 20.04 and installed Busybox in the script:

resource "aws_instance" "example" {
  ami = "ami-05f7491af5eef733a"
  instance_type = "t2.micro"
  vpc_security_group_ids = [ aws_security_group.instance.id ]
  tags = {
    "Name" = "terraform-example"
  }
  user_data = <<-EOF
              #!/bin/bash
              sudo apt-get update -y
              sudo apt-get install -y busybox
              echo "Hello, World" > index.html
              nohup busybox httpd -f -p 8080 &
              EOF
}

@mikerossiter
Copy link

Hi guys. I'm in a similar situation. I have tried these suggestions but the web server doesn't seem to want to start. Any ideas?

@Gang-Peng
Copy link

I cannot find that image (ami-0c55b159cbfafe1f0) anymore in us-east-2. The closest one is "ami-03a5def6b0190cef7".
image

@temutai
Copy link

temutai commented Jul 21, 2024

I cannot find that image (ami-0c55b159cbfafe1f0) anymore in us-east-2. The closest one is "ami-03a5def6b0190cef7". image

Pick any available free tier Ubuntu instance. Also it doesn't have to be us-east-2. I did it in us-east-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants