The resource block appears to be in good order.
However, I would like to note that it appear to have issues with quotes. Try using straight quotes " and try this again.
It would have helped if you had shared the code in a code block:
Could I please see the wording of the question? The terraform works to create a file /home/bob/datacenter-kp.pem. It sounds like the grader script does NOT expect that file name. So the question may clarify why that is.
I don’t have any way to check what the grader is doing, unfortunately. The problem also says the script file should be /home/bob/terraform/main.tf. If that’s the case, I have no idea what else they’re checking. But your file is syntactically correct and runs – that I’ve verified.
After creating the tls_private_key, you’ll have to create the key_pair with the aws_key_pair resource and set the public key to the public_key_openssh generated by the tls_private_key resource.