Skip to content

Commit

Permalink
Add key pair resource in Terraform configuration
Browse files Browse the repository at this point in the history
Existing key pair referenced in a separate resource instead of directly in instance resource.
  • Loading branch information
emilyllim committed Oct 26, 2023
1 parent b439df3 commit 99b78b5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ resource "aws_security_group" "ingress_all" {
}
}

resource "aws_key_pair" "benchrun_keypair" {
key_name = "bench-runner"
public_key = file("~/.ssh/id_rsa.pub")
}

resource "aws_instance" "bench_runner" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
key_name = "bench-runner"
key_name = aws_key_pair.benchrun_keypair.key_name
vpc_security_group_ids = ["${aws_security_group.ingress_all.id}"]
subnet_id = aws_subnet.subnet1.id

Expand Down

0 comments on commit 99b78b5

Please sign in to comment.