-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathmain.tf
More file actions
36 lines (29 loc) · 683 Bytes
/
main.tf
File metadata and controls
36 lines (29 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
variable "region" {
default = "us-east-2"
}
# Random string for resources
resource "random_string" "suffix" {
length = 5
special = false
upper = false
}
locals {
rs = "${random_string.suffix.id}"
}
output "aws_region" {
value = var.region
}
resource "tls_private_key" "operator" {
algorithm = "RSA"
}
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
key_name = "operator-${local.rs}"
public_key = tls_private_key.operator.public_key_openssh
}
# write ssh key to file
resource "local_file" "ssh_key" {
content = tls_private_key.operator.private_key_pem
filename = "${path.module}/ssh_key.pem"
file_permission = "0700"
}