Hi@akhtar,
You can use aws_key_pair resource n terraform. It will help you to create a key. I have attached one example below.
variable "Enter_ur_key_name" {default="my-key1"}
resource "tls_private_key" "example" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "aws_key_pair" "generated_key" {
key_name = var.Enter_ur_key_name
public_key = tls_private_key.example.public_key_openssh
}
Hope this will help.