-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.tf
57 lines (45 loc) · 1.32 KB
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
resource "tls_private_key" "tls_key_pair" {
algorithm = "RSA"
rsa_bits = 2048
}
resource "aws_ssm_parameter" "ssm_key_pair_private_key" {
name = format("/ec2/key-pair/%s/private-rsa-key-pem", var.name)
description = "TLS Private Key"
type = "String"
value = tls_private_key.tls_key_pair.private_key_pem
overwrite = true
tags = var.tags
depends_on = [
tls_private_key.tls_key_pair
]
}
resource "aws_ssm_parameter" "ssm_key_pair_private_key_rsa" {
name = format("/ec2/key-pair/%s/public-rsa-key-pem", var.name)
description = "TLS Public Key (OpenSSH - RSA)"
type = "String"
value = tls_private_key.tls_key_pair.public_key_pem
overwrite = true
tags = var.tags
depends_on = [
tls_private_key.tls_key_pair
]
}
resource "aws_ssm_parameter" "ssm_key_pair_public_key" {
name = format("/ec2/key-pair/%s/public-rsa-key-openssh", var.name)
description = "TLS Public Key"
type = "String"
value = tls_private_key.tls_key_pair.public_key_openssh
overwrite = true
tags = var.tags
depends_on = [
tls_private_key.tls_key_pair
]
}
resource "aws_key_pair" "key_pair" {
key_name = var.name
public_key = tls_private_key.tls_key_pair.public_key_openssh
tags = var.tags
depends_on = [
tls_private_key.tls_key_pair
]
}