Allocate new static IP and create new instance EC2


How to allocate new static ip in Elastic IP with terraform?
How to get this static ip and associate a new EC2 instance

I’m tryed this, but not a same IP

resource “aws_eip” “default” {
instance = “${aws_eip.default.public_ip}”
vpc = true

resource “aws_instance” “newserver” {
ami = “${}”
instance_type = “t2.micro”

ERROR: Incorrect attribute value type

on line 19, in resource “aws_route53_record” “client-dns”:
19: records = aws_eip.default.public_ip
| aws_eip.default.public_ip is “”

Inappropriate value for attribute “records”: set of string required.

In the EIP resource, the parameter instance should point to the EC2 instance, not the EIP itself: instance =