Skip to content

Instantly share code, notes, and snippets.

@AmanM13
Created June 17, 2020 12:40
Show Gist options
  • Save AmanM13/6069c5d576066ace8942c456db744a80 to your computer and use it in GitHub Desktop.
Save AmanM13/6069c5d576066ace8942c456db744a80 to your computer and use it in GitHub Desktop.
//Creating Key
resource "tls_private_key" "tls_key" {
algorithm = "RSA"
}
//Generating Key-Value Pair
resource "aws_key_pair" "generated_key" {
key_name = "Aman-env-key"
public_key = "${tls_private_key.tls_key.public_key_openssh}"
depends_on = [
tls_private_key.tls_key
]
}
//Saving Private Key PEM File
resource "local_file" "key-file" {
content = "${tls_private_key.tls_key.private_key_pem}"
filename = "rg-env-key.pem"
depends_on = [
tls_private_key.tls_key
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment