Hello, I am new to terraform and aws. I am stuck with this problem for couple of days now. I went through every possible post related to my issue but I am not able to resolve this issue.
I am unable to connect to EC2 instance and receive the following error:-
There was a problem connecting to your instance
We were unable to connect to your instance. Make sure that your instance’s network settings are configured correctly for EC2 Instance Connect. For more information, see Task 1: Configure network access to an instance.
This is how my main.tf file looks
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.5.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-04505e74c0741db8d"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.instance.id]
user_data = <<-EOF
#!/bin/bash
echo "Hello, World" > index.html
nohup busybox httpd -f -p 8080 &
EOF
tags = {
Name = "terraform-example"
}
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
Also sharing my netstat. Getting this same issue on both Windows and Debian11. I am not sure what I am doing wrong but surely the required port is not opening.
jeevan@jaswik:~$ netstat -tunlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:57343 0.0.0.0:* LISTEN 4129/steam
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp6 0 0 :::5355 :::* LISTEN -
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 0.0.0.0:58533 0.0.0.0:* -
udp 0 0 0.0.0.0:27036 0.0.0.0:* 4129/steam
udp 0 0 224.0.0.251:5353 0.0.0.0:* 2691/chromium --sho
udp 0 0 0.0.0.0:5353 0.0.0.0:* -
udp 0 0 0.0.0.0:5355 0.0.0.0:* -
udp6 0 0 :::59294 :::* -
udp6 0 0 :::5353 :::* -
udp6 0 0 :::5355 :::* -
I will greatly appreciate any form of help related to this issue. Thanks in advance.