imohd23 / Terraws-script

This repo made to support this article, New Documentation is coming
MIT License
3 stars 18 forks source link

Error: InvalidAMIID.NotFound: The image id '[ami-0c3e74fa87d2a4227]' does not exist #4

Closed calidude25 closed 2 years ago

calidude25 commented 2 years ago

The AMI specified in this is not public

module.auto_scaling.aws_launch_configuration.this[0]: Creating... ╷ │ Error: InvalidAMIID.NotFound: The image id '[ami-0c3e74fa87d2a4227]' does not exist │ status code: 400, request id: e4d41ef9-e47b-4c4e-a6ba-9977c98ff41b │ │ with module.auto_scaling.aws_launch_configuration.this[0], │ on .terraform/modules/auto_scaling/main.tf line 4, in resource "aws_launch_configuration" "this": │ 4: resource "aws_launch_configuration" "this" {

imohd23 commented 2 years ago

Hi! Thanks for passing by. So, the AMI might be not wrong, the region is not Ireland. What is the region? If so, please go to the console -> ec2 -> launch instance -> select the AMI and replace the AMI in the template.

Let me know what you get.

calidude25 commented 2 years ago

hmm, not sure where you are getting Ireland as I'm using us-west-2a

I generated a EC2 from Packer tutorial - https://learn.hashicorp.com/tutorials/packer/aws-get-started-build-image?in=packer/aws-get-started

aws_autoscaling_attachment.asg_attachment_bar: Creating... ╷ │ Error: Failure attaching AutoScaling Group Terraform_test_auto_scaling_lc-20220118231440851900000004 with Elastic Load Balancer: elb-example: ValidationError: Provided Load Balancers may not be valid. Please ensure they exist and try again. │ status code: 400, request id: ae81b423-4166-4141-b3a8-c131b82e6920 │ │ with aws_autoscaling_attachment.asg_attachment_bar, │ on main.tf line 185, in resource "aws_autoscaling_attachment" "asg_attachment_bar": │ 185: resource "aws_autoscaling_attachment" "asg_attachment_bar" { │ ╵

imohd23 commented 2 years ago

Let's break it into two points:

1- each region has its own AMI, if you're using us-west-2a, it means you'll have to do the steps I shared to get the corresponding AMI for the instance that is declared in the template.

2- did the template failed and you re-triggered it again? What are the steps you performed that led into this error? Because it states that the elb isn't ready yet. Check what you can see in the console.

calidude25 commented 2 years ago

Hi, believe it took this time as I ran "terraform plan -out configplan.out" to save the plan and ran "terraform apply configplan.out" and will check website shortly to see if is up -

aws_autoscaling_attachment.asg_attachment_bar: Creation complete after 1s [id=Terraform_test_auto_scaling_lc-20220118233827253600000004-20220118233829510900000005]

Apply complete! Resources: 27 added, 0 changed, 0 destroyed.

Outputs:

elb_link = "elb-example-2071301647.us-west-2.elb.amazonaws.com"

calidude25 commented 2 years ago

When I go to hit the public IP - 54.245.145.251 it times out and doesn't take me to the Wordpress site

ssh to the instance and I see everything has installed under

ubuntu@ip-10-0-101-67:/home/ec2-user$ ls aws_TerraPress ubuntu@ip-10-0-101-67:/home/ec2-user$ cd aws_TerraPress/ ubuntu@ip-10-0-101-67:/home/ec2-user/aws_TerraPress$ ls -al total 28 drwxr-xr-x 4 root root 4096 Jan 18 23:41 . drwxr-xr-x 3 root root 4096 Jan 18 23:41 .. -rw-r--r-- 1 root root 1056 Jan 18 23:41 docker-compose.yaml drwxr-xr-x 8 root root 4096 Jan 18 23:41 .git -rw-r--r-- 1 root root 1072 Jan 18 23:41 LICENSE drwxr-xr-x 3 root root 4096 Jan 18 23:41 nginx -rw-r--r-- 1 root root 55 Jan 18 23:41 README.md

What am I missing? appreciate more help as think I'm really close

calidude25 commented 2 years ago

What flavor of linux is your script looking for with the ami as not seeing anything specified in your documentation.

I've tried RHEL and Ubuntu, is it Centos? because the script is failing on yum install with Ubuntu and can't run Docker on RHEL....

calidude25 commented 2 years ago

it means you'll have to do the steps I shared to get the corresponding AMI for the instance that is declared in the template.

Can you point me to these steps?

calidude25 commented 2 years ago

Found it searching under eu-west-1 (Ireland)

amzn2-ami-hvm-2.0.20200617.0-x86_64-gp2 - ami-0c3e74fa87d2a4227 Amazon Linux 2 AMI 2.0.20200617.0 x86_64 HVM gp2 Root device type: ebs Virtualization type: hvm ENA Enabled: Yes

This is version - Kernel 4.14.181-140.257.amzn2.x86_64 on an x86_64

Equivalent is this in us-west-2

Amazon Linux 2 AMI (HVM) - Kernel 4.14, SSD Volume Type - ami-0ecf760d3d7e1fefa (64-bit x86) / ami-0bfea997624092f92 (64-bit Arm) Amazon Linux 2 comes with five years support. It provides Linux kernel 4.14 tuned for optimal performance on Amazon EC2, systemd 219, GCC 7.3, Glibc 2.26, Binutils 2.29.1, and the latest software packages through extras. This AMI is the successor of the Amazon Linux AMI that is now under maintenance only mode and has been removed from this wizard. Root device type: ebs Virtualization type: hvm ENA Enabled: Yes

calidude25 commented 2 years ago

Able to execute Docker, however other issues that will address in a new issue ticket