Eks-getting-started fails terraform plan

I’m attempting to follow eks-getting-started as referenced from this Amazon document. I clone the git repo, change into the example directory, and run the plan command. It fails with the message

Error: subnet_ids: attribute supports 1 item as a minimum, config has 0 declared

  on eks-worker-nodes.tf line 41, in resource "aws_eks_node_group" "demo":
  41: resource "aws_eks_node_group" "demo" {

The line it doesn’t like is

 subnet_ids         = aws_subnet.demo[*].id

This is the Terraform-provided example. And it doesn’t work. I’m finding this a common occurrence.

Has anyone tried the example? Or might be able to point me in a useful direction for troubleshooting?

Thanks.

No one?

It’s odd, as the output shows that both aws_subnet instances are created.

aws_subnet.demo[0]: Refreshing state... [id=subnet-079308300357914c0]
aws_subnet.demo[1]: Refreshing state... [id=subnet-0aaa7205bceaf864e]
aws_route_table.demo: Refreshing state... [id=rtb-032a20a3c78133265]
aws_security_group_rule.demo-cluster-ingress-workstation-https: Refreshing state... [id=sgrule-3389499673]
aws_route_table_association.demo[0]: Refreshing state... [id=rtbassoc-0267c74651d3bfae0]
aws_route_table_association.demo[1]: Refreshing state... [id=rtbassoc-09b597dfcf7ff2967]

Error: subnet_ids: attribute supports 1 item as a minimum, config has 0 declared

  on eks-worker-nodes.tf line 41, in resource "aws_eks_node_group" "demo":
  41: resource "aws_eks_node_group" "demo" {

I’ve created a PR to correct this issue.

Did you initialise the backend? Or ran something before and destroyed it?
Happened with me as well and the issue was that my s3 backend was initialised and i had deleted resources manually!