How to do ssh in EC2 instance using Terraform

0 votes

Hi Guys,

I am trying to do ssh in EC2 instance using Terraform. Can anyone help me with this?

Jun 15, 2020 in Terraform by akhtar
• 38,170 points
3,462 views

1 answer to this question.

0 votes

Hi@akhtar,

To ssh in your EC2 instance, you have to provide user and private key. In Terraform you can use connection keyword to ssh in EC2 instance. I have attached one example for your reference.

 connection {
    type     = "ssh"
    user     = "ec2-user"
    private_key = file("C:/Users/Nadeem Akhtar/Downloads/mysecure.pem")
    host     = aws_instance.web.public_ip
  }
answered Jun 15, 2020 by MD
• 95,180 points

Related Questions In Terraform

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,180 points
966 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,180 points
1,373 views
+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,180 points
1,150 views
0 votes
1 answer

How to launch one EC2 instance for WordPress using Terraform?

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

answered Sep 9, 2020 in Terraform by MD
• 95,180 points
147 views
0 votes
1 answer
0 votes
1 answer

How to attach Elastic IP in EC2 instance using Terraform code?

Hi@akhtar, You can use aws_eip resource in your ...READ MORE

answered Jul 22, 2020 in Terraform by MD
• 95,180 points
3,580 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,180 points
3,761 views