在本地exec terraform中调用shell脚本
我试图从Terraform中的本地exec块中调用shell脚本。shell脚本基本上使用terraform输出(大约8个输出)并生成一个YML文件(作为变量),我稍后使用cat>方法使用该文件。在脚本中,我还使用Ssh私钥等进行了一些格式化。这真的不管用。 最好的方法是什么?我可以在本地exec中使用任何Linux命令吗?有没有更好的方法来利用地形输出?在本地exec terraform中调用shell脚本,terraform,terraform-provider-aws,Terraform,Terraform Provider Aws,我试图从Terraform中的本地exec块中调用shell脚本。shell脚本基本上使用terraform输出(大约8个输出)并生成一个YML文件(作为变量),我稍后使用cat>方法使用该文件。在脚本中,我还使用Ssh私钥等进行了一些格式化。这真的不管用。 最好的方法是什么?我可以在本地exec中使用任何Linux命令吗?有没有更好的方法来利用地形输出? 我主要想使用来自不同模块的某些输出并创建一个YML文件(如键值对)。为什么不使用模板文件: data "template_file" "ku
我主要想使用来自不同模块的某些输出并创建一个YML文件(如键值对)。为什么不使用模板文件:
data "template_file" "kube_config" {
template = "${file("${path.module}/kubeconfig.tpl")}"
vars {
vpc_name = "${var.vpc_name}"
eks_name = "${aws_eks_cluster.eks_cluster.id}"
eks_endpoint = "${aws_eks_cluster.eks_cluster.endpoint}"
eks_cert = "${aws_eks_cluster.eks_cluster.certificate_authority.0.data}"
}
}
其中,用于模板化的文件如下所示:
apiVersion: v1
clusters:
- cluster:
server: ${eks_endpoint}
certificate-authority-data: ${eks_cert}
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: aws
name: aws-${vpc_name}
current-context: aws-${vpc_name}
kind: Config
preferences: {}
users:
- name: aws
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
command: heptio-authenticator-aws
args:
- "token"
- "-i"
- "${eks_name}"
#- "-r"
#- "<role ARN>"
#env:
#- name: AWS_PROFILE
# value: "<profile>"
你能编辑你的问题来显示你已经尝试了什么,然后清楚地解释什么不适合你吗?理想情况下,这应该是一种形式。如果它出错,那么也包括完整的错误输出。谢谢Sevillo,谢谢你的回复。将尝试使用模板\u fileHi@Sevillo进行测试。请你看看我的问题:,它也与本地执行有关。
resource "null_resource" "config_setup" {
triggers {
kubeconfig_change = "${data.template_file.kube_config.rendered}"
configmap_change = "{local.config-map-aws-auth}"
}
provisioner "local-exec" {
command = "mkdir -p ${var.vpc_name}_output_EKS; echo '${data.template_file.kube_config.rendered}' >${var.vpc_name}_output_EKS/kubeconfig"
}
}