Actually I have this problem, to execute terraform plan, and I not have idea to solve, I review all configurations and is correct and the code I not have problems, is desesperating beucause not exists more information for this problems.
Any idea to solve, please?? and Thank you for helm me.
Error: Invalid index
on .terraform/modules/eks/terraform-aws-modules-terraform-aws-eks-1be1a02/cluster.tf line 52, in resource “aws_security_group_rule” “cluster_egress_internet”:
52: security_group_id = aws_security_group.cluster[0].id
|----------------
| aws_security_group.cluster is empty tuple
The given key does not identify an element in this collection value.
It means that there is nothing in the aws_security_group.cluster[0] variable, because it’s not been created, and so there is no id attribute.
Probably because you’re missing a parameter in the call to the module, so check the variables defined inside it.
Is it a module you wrote yourself?
Thanks for posting this…Just had a similar issue in Azure. Deleted the remote state file in the Blob Container and the local .tfstate and terraform planned as expected again. I had forgotten that I manually added some resources to the environment via the Azure Portal which weren’t part of the original script, then destroyed it and manually deleted the remnants. All of that extra activity confused the heck out of the state files and rightly so.
For me it was a resource that I manually deleted but still record in remote tfstate. I have to use azure state rm to remove it. Don’t forget your quotes around the resource when using azure state rm.