This is my code anyone can help to resolve this error
provider “aws” {
region = “us-east-1”
access_key = “"
secret_key = "************”
}
resource “aws_instance” “terraform” {
ami = “ami-0866a3c8686eaeeba”
instance_type = “t2.micro”
name = “terraform”
}
resource “aws_eip” “terraform_eip” {
vpc = true
}
resource “aws_eip_association” “eip_assoc” {
instance_id = aws_instance.terraform.id
allocation_id = aws_eip.terraform_eip.id
}
resource “aws_security_group” “allow_ip” {
name = “sg_terraform”
ingress{
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["${aws_eip.terraform_eip.public_ip/}"]
}
}
ubuntu@SW-VM-302:~/tfdemo$ terraform plan
╷
│ Warning: Argument is deprecated
│
│ with aws_eip.terraform_eip,
│ on ec2witheip.tf line 12, in resource “aws_eip” “terraform_eip”:
│ 12: vpc = true
│
│ use domain attribute instead
╵
╷
│ Error: Reference to undeclared resource
│
│ on ec2witheip.tf line 15, in resource “aws_eip_association” “eip_assoc”:
│ 15: instance_id = aws_instance.terraform.id
│
│ A managed resource “aws_instance” “terraform” has not been declared in the root module.