Skip to content

Commit 7bfeaaa

Browse files
committed
generate key pair from module
1 parent ff86962 commit 7bfeaaa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ resource "aws_key_pair" "ansible" {
88
}
99
}
1010

11+
module "key-pair" {
12+
source = "terraform-aws-modules/key-pair/aws"
13+
14+
key_name = "ansible-module"
15+
create_private_key = true
16+
}
17+
18+
resource "local_file" "ansible-module-public-key" {
19+
filename = "public_key"
20+
content = module.key-pair.public_key_pem
21+
}
22+
23+
resource "local_file" "ansible-module-private-key" {
24+
filename = "private_key"
25+
content = module.key-pair.private_key_pem
26+
}
27+
1128
resource "aws_instance" "terraform-gitlab-docker-runner" {
1229
ami = "ami-074cc9cf7a6bfbd02"
1330
instance_type = "c6g.medium"

0 commit comments

Comments
 (0)