generate key, use variables
This commit is contained in:
parent
ace065d9d2
commit
c5de5f6c9f
17
main.tf
17
main.tf
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
resource "aws_vpc" "sgtm_vpc" {
|
resource "aws_vpc" "sgtm_vpc" {
|
||||||
cidr_block = "10.123.0.0/16"
|
cidr_block = "10.123.0.0/16"
|
||||||
enable_dns_hostnames = true
|
enable_dns_hostnames = true
|
||||||
|
@ -66,9 +68,20 @@ resource "aws_security_group" "sgtm_sg" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "tls_private_key" "key" {
|
||||||
|
algorithm = var.tls_key_algorithm
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_key_pair" "sgtm_auth" {
|
resource "aws_key_pair" "sgtm_auth" {
|
||||||
key_name = "sgtmkey"
|
key_name = "${var.name_prefix}-key-${var.name_suffix}"
|
||||||
public_key = file("~/.ssh/sgtmkey.pub")
|
public_key = tls_private_key.key.public_key_openssh
|
||||||
|
|
||||||
|
provisioner "local-exec" {
|
||||||
|
command = <<EOF
|
||||||
|
echo "${tls_private_key.key.private_key_pem}" > key.pem
|
||||||
|
chmod 0600 key.pem
|
||||||
|
EOF
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_instance" "dev_node" {
|
resource "aws_instance" "dev_node" {
|
||||||
|
|
Loading…
Reference in New Issue