Unable to deploy EKS cluster

Hi,

When I try to deploy the EKS cluster with the nodes, following the same article

It gives me the following errors, it was working fine earlier


│ Error: Invalid index
│
│   on eks.tf line 44, in resource "aws_eks_cluster" "demo_eks":
│   44:       data.aws_subnets.public.ids[1],
│     ├────────────────
│     │ data.aws_subnets.public.ids is list of string with 1 element
│
│ The given key does not identify an element in this collection value: the given index is greater than or equal to the length of the        
│ collection.
╵
╷
│ Error: Invalid index
│
│   on eks.tf line 45, in resource "aws_eks_cluster" "demo_eks":
│   45:       data.aws_subnets.public.ids[2]
│     ├────────────────
│     │ data.aws_subnets.public.ids is list of string with 1 element
│
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│
│   on nodes.tf line 235, in resource "aws_cloudformation_stack" "autoscaling_group":
│  235:       VPCZoneIdentifier: ["${data.aws_subnets.public.ids[0]}","${data.aws_subnets.public.ids[1]}", "${data.aws_subnets.public.ids[2]}"]
│     ├────────────────
│     │ data.aws_subnets.public.ids is list of string with 1 element
│
│ The given key does not identify an element in this collection value: the given index is greater than or equal to the length of the        
│ collection.
╵
╷
│ Error: Invalid index
│
│   on nodes.tf line 235, in resource "aws_cloudformation_stack" "autoscaling_group":
│  235:       VPCZoneIdentifier: ["${data.aws_subnets.public.ids[0]}","${data.aws_subnets.public.ids[1]}", "${data.aws_subnets.public.ids[2]}"]
│     ├────────────────
│     │ data.aws_subnets.public.ids is list of string with 1 element
│
│ The given key does not identify an element in this collection value.

It looks like the error is due to the fact that data.aws_subnets.public.ids only contains one element, but the code is trying to access three elements. but EKS needs to deploy in three availability zones

eks.tf

vpc_config {
subnet_ids = [
data.aws_subnets.public.ids[0],
data.aws_subnets.public.ids[1],
data.aws_subnets.public.ids[2]
]
}