How to attach Elastic IP in EC2 instance using Terraform code

0 votes

Hi Guys,

I have launch one EC2 instance in AWS using Terraform code. Now I want to add one Elastic IP to this instance. How can I do that?

Jul 22, 2020 in Terraform by akhtar
• 38,180 points
3,908 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use aws_eip resource in your Terraform code. You have to associate your EIP with your instance id. You can use the below-given example.

resource "aws_eip" "lb" {
  instance = "${aws_instance.web.id}"
  vpc      = true
}
answered Jul 22, 2020 by MD
• 95,220 points

Related Questions In Terraform

0 votes
1 answer

How to do ssh in EC2 instance using Terraform?

Hi@akhtar, To ssh in your EC2 instance, you ...READ MORE

answered Jun 15, 2020 in Terraform by MD
• 95,220 points
3,708 views
0 votes
1 answer

How to create a rds snapshot from running rds instance in AWS using terraform?

Hi, I think you can use aws_db_instance resource to ...READ MORE

answered Jul 20, 2020 in Terraform by MD
• 95,220 points
1,027 views
0 votes
1 answer

How to launch EC2 windows instance with powershell script using terraform?

Hi, In your Terraform code, you have written ...READ MORE

answered Jul 21, 2020 in Terraform by MD
• 95,220 points
1,480 views
0 votes
1 answer

How to create a route table in AWS using Terraform code?

Hi@akhtar, You can use aws_route_table resources in your ...READ MORE

answered Jul 21, 2020 in Terraform by MD
• 95,220 points
1,032 views
0 votes
1 answer

Create Snapshot of EBS and attach to EC2 using Terraform

You can also create a snapshot using ...READ MORE

answered Oct 29, 2018 in AWS by Priyaj
• 58,120 points
1,032 views
0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer

How to attach an elastic load balancer with ec2 instance using Terraform?

Hi@akhtar, You can use aws_elb_attachment resource in Terraform. ...READ MORE

answered Aug 17, 2020 in Terraform by MD
• 95,220 points
1,251 views
0 votes
1 answer

How to attach an EBS volume to EC2 instance using terraform?

Hi@akhtar, You can use aws_volume_attachment resource to attach ...READ MORE

answered Jun 12, 2020 in Terraform by MD
• 95,220 points
4,099 views