Skip to content

Instantly share code, notes, and snippets.

@rohitg00
Last active June 14, 2020 15:18
Show Gist options
  • Save rohitg00/bccfab41976749b610186ca3e47fd358 to your computer and use it in GitHub Desktop.
Save rohitg00/bccfab41976749b610186ca3e47fd358 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 = "rg-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