0
votes

I have 2 directories:

  • aws/
  • k8s/

In the aws/ dir, I've provisioned an EKS cluster and EKS node group (among other things) using the Terraform AWS provider. That's been applied and everything looks good there.

When trying to then create a Kubernetes provider plan in k8s/ and create a Persistent Volume resource it requires the EBS volume ID.

Terraform Kubernetes Persistent Volume Resource

How do I get the EBS volume ID from the other .tfstate file from a Kubernetes provider plan?

1

1 Answers

1
votes

So as I understand it, you want to reference resource from another state file. To do that you can use the following example:

data "terraform_remote_state" "aws_state" {
  backend = "remote"

  config = {
  organization = "hashicorp"
  workspaces = {
    name = "state-name"
  }
}

}

And once you have data resources available you can reference ebs volume in the following way:

data.terraform_remote_state.aws_state.outputs.ebs_volume_id

Remember to create an output called ebs_volume_id