简体   繁体   English

如何在 Kubernetes 供应商计划中引用 AWS 供应商计划的输出?

[英]How to reference the output from AWS provider plan in Kubernetes provider plan?

I have 2 directories:我有2个目录:

  • aws/
  • k8s/

In the aws/ dir, I've provisioned an EKS cluster and EKS node group (among other things) using the Terraform AWS provider.aws/目录中,我使用 Terraform AWS 提供程序预配了一个 EKS 集群和 EKS 节点组(除其他外)。 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.然后尝试在k8s/创建 Kubernetes 提供程序计划并创建持久卷资源时,它需要 EBS 卷 ID。

Terraform Kubernetes Persistent Volume Resource Terraform Kubernetes 持久卷资源

How do I get the EBS volume ID from the other .tfstate file from a Kubernetes provider plan?如何从 Kubernetes 提供商计划的其他.tfstate文件中获取 EBS 卷 ID?

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:一旦您有可用的数据资源,您可以通过以下方式引用 ebs 卷:

data.terraform_remote_state.aws_state.outputs.ebs_volume_id

Remember to create an output called ebs_volume_id记得创建一个名为ebs_volume_id的输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM