resource "tls_private_key" "mlkey" { algorithm = "RSA" rsa_bits = 4096 } resource "aws_key_pair" "mlkey" { key_name = "mlboxkey" public_key = tls_private_key.mlkey.public_key_openssh provisioner "local-exec" { command = "echo '${tls_private_key.mlkey.private_key_pem}' > ./${var.output_ssh_key} & chmod 400 ${var.output_ssh_key}" } } data "aws_ami" "aws_linux_ami" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["debian-12-amd64-*"] } } resource "aws_instance" "ml-box" { ami = data.aws_ami.aws_linux_ami.id instance_type = var.instance_type key_name = aws_key_pair.mlkey.key_name vpc_security_group_ids = [ aws_security_group.allow_tls.id ] tags = { Name = "terragenerated-simple-ec2" } } # resource "ansible_host" "ml-box" { # name = aws_instance.ml-box.public-ip # groups = [ ] # }