docs: add Terraform certification notes and tasks
This commit is contained in:
39
terraform/001/main.tf
Normal file
39
terraform/001/main.tf
Normal file
@@ -0,0 +1,39 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 6.0"
|
||||
}
|
||||
tls = {
|
||||
source = "hashicorp/tls"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "~> 2.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
# Generate an RSA private key locally
|
||||
resource "tls_private_key" "devops_kp" {
|
||||
algorithm = "RSA"
|
||||
rsa_bits = 4096
|
||||
}
|
||||
|
||||
# Import the public half into AWS as an RSA key pair
|
||||
resource "aws_key_pair" "devops_kp" {
|
||||
key_name = "devops-kp"
|
||||
public_key = tls_private_key.devops_kp.public_key_openssh
|
||||
}
|
||||
|
||||
# Persist the private key to disk
|
||||
resource "local_sensitive_file" "devops_kp_pem" {
|
||||
content = tls_private_key.devops_kp.private_key_pem
|
||||
filename = "/home/bob/devops-kp.pem"
|
||||
file_permission = "0400"
|
||||
}
|
||||
Reference in New Issue
Block a user