First, pleaseuse a code block for this kind of code – pasting it directly into the edit window as you did garbles your code. Here’s what I think you meant:
Your code may lack spaces in some points of it that made it syntactically invalid. I can’t tell, again, because your code is garbled, and I had to add in spaces to make it parse correctly in terraform. The other possibility is that you’re not naming some of the items as the task expects.
Assuming I got your code correctly, then it does generate a PEM file that looks valid. But without knowing the exact wording of the task (this changes from each time you call up the task), I can’t be sure why the grader is unhappy.
This may well be your problem – this is wrong. You need to remove the quote marks of this one, since content needs to be set to a variable to work here.