Update main.tf

This commit is contained in:
Ryan Malloy 2024-11-11 07:58:24 +00:00
parent f2079c0825
commit 39e329c99e
1 changed files with 17 additions and 0 deletions

17
main.tf
View File

@ -30,6 +30,23 @@ resource "aws_route_table_association" "public-rt-association" {
route_table_id = aws_route_table.public-rt.id route_table_id = aws_route_table.public-rt.id
} }
# Generates a secure private key and encodes it as PEM
resource "tls_private_key" "key_pair" {
algorithm = "RSA"
rsa_bits = 4096
}
# Create the Key Pair
resource "aws_key_pair" "key_pair" {
key_name = "${lower(var.app_name)}-${lower(var.app_environment)}-windows-${lower(var.aws_region)}"
public_key = tls_private_key.key_pair.public_key_openssh
}
# Save file
resource "local_file" "ssh_key" {
filename = "${aws_key_pair.key_pair.key_name}.pem"
content = tls_private_key.key_pair.private_key_pem
}
# Bootstrapping PowerShell Script # Bootstrapping PowerShell Script
data "template_file" "windows-userdata" { data "template_file" "windows-userdata" {