It should be
encoded_key = file("${path.module}/public_key.pem")
not
encoded_key = filebase64("${path.module}/public_key.pem")