forked from DNXLabs/terraform-aws-eb-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2-keypair.tf
31 lines (27 loc) · 995 Bytes
/
ec2-keypair.tf
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
resource "tls_private_key" "this" {
count = var.key_name == "" ? 1 : 0
algorithm = "RSA"
}
resource "aws_key_pair" "key" {
count = var.key_name == "" ? 1 : 0
key_name = "eb-${var.environment}-${var.name}"
public_key = tls_private_key.this[0].public_key_openssh
}
resource "aws_ssm_parameter" "ssh_private_key_pem" {
count = var.key_name == "" ? 1 : 0
name = "/eb/${var.environment}/${var.name}/ssh_private_key_pem"
type = "SecureString"
value = tls_private_key.this[0].private_key_pem
}
resource "aws_ssm_parameter" "ssh_public_key_pem" {
count = var.key_name == "" ? 1 : 0
name = "/eb/${var.environment}/${var.name}/ssh_public_key_pem"
type = "SecureString"
value = tls_private_key.this[0].public_key_pem
}
resource "aws_ssm_parameter" "ssh_public_key_openssh" {
count = var.key_name == "" ? 1 : 0
name = "/eb/${var.environment}/${var.name}/ssh_public_key_openssh"
type = "SecureString"
value = tls_private_key.this[0].public_key_openssh
}