Issue in Terraform task

I am working on task 1 of terraform, but facing issue when submitting. All things seems to be correct and done using terraform only but it is giving error as:

I have attached the solution.

resource "tls_private_key" "rsa_key"{
    algorithm = "RSA"
    rsa_bits = 4096
}

resource "aws_key_pair" "aws_key" {
  key_name   = "datacenter-kp"
  public_key = tls_private_key.rsa_key.public_key_openssh
}

resource "local_file" "key_local" {
  content  = tls_private_key.rsa_key.private_key_pem
  filename = "/home/bob/datacenter-kp.pem"
}

What can be the issue here…

Did you apply the terraform? The error suggests that you didn’t since your solution looks right

If you did apply it, you would probably have got an error like datacenter-kp doesn't exist or or its type is not rsa which is a grader error, and there is an internal ticket for that.

Hi @devansharma92

I just checked it, and it worked fine. Like Alistair said, you might have forgotten to run terraform apply.

1 Like