Terraform Issue - Can't find Data Source in Sub Module? I'm fairly new to Terraform and have been following this example on creating an EKS cluster - https://github.com/terraform-providers/terraform-provider-aws/tree/master/examples/eks-getting-started

Only difference is that I've broken the structure up into modules:

-main.tf
-vpc
   vpc.tf
   vars.tf
-eks
   eks-cluster.tf
   eks-worker-nodes.tf
   vars.tf
   outputs.tf


In 'main.tf' I've got the following

provider "aws" {
  region     = "us-east-1"
}

# Using these data sources allows the configuration to be
# generic for any region.
data "aws_region" "current" {}

data "aws_availability_zones" "available" {}


When I run a 'terraform plan' I get the following error which comes from eks-worker-nodes.tf :

 * module.eks.local.demo-node-userdata: local.demo-node-userdata: 
 Resource 'data.aws_region.current' not found for variable 
'data.aws_region.current.name'       


Is there any reason why it wouldn't be able to access the data source? I'm fairly new to Terraform but I've done some googling and couldn't find a clear answer :/
You need to pass that info to your module or also declare it in your module again. For example, for the region, pass it as a variable to the module:

module "foo" {
  ...
  current_region = "${data.aws_region.current.name}"
  ...
}


Or add it inline in your module, just like you did in your main.tf