[英]How to obtain public key from Openstack using Terraform and save it locally?
I'm trying to obtain a public key from Openstack (to later save it on local machine) using data source openstack_compute_keypair_v2
in Terraform:我正在尝试使用 Terraform 中的数据源
openstack_compute_keypair_v2
从 Openstack 获取公钥(稍后将其保存在本地机器上):
data "openstack_compute_keypair_v2" "app_public_key" {
name = "app-key"
}
, but when I run terraform apply
nothing happens. ,但是当我运行
terraform apply
什么也没有发生。 (The key exists and the name is also correct.) (密钥存在,名称也正确。)
I assumed (maybe wrong) that I need to save them manually so I used local_file
resource.我假设(可能是错误的)我需要手动保存它们,所以我使用了
local_file
资源。
resource "local_file" "app_cert" {
content = "${openstack_compute_keypair_v2.app_public_key.public_key}"
filename = "${path.module}/app.cert"
}
But I am getting: Error: resource 'local_file.app_cert' config: unknown resource 'openstack_compute_keypair_v2.app_public_key' referenced in variable openstack_compute_keypair_v2.app_public_key.public_key
但我得到:
Error: resource 'local_file.app_cert' config: unknown resource 'openstack_compute_keypair_v2.app_public_key' referenced in variable openstack_compute_keypair_v2.app_public_key.public_key
According to the documentation there is such attribute.根据文档,有这样的属性。 What am I doing wrong?
我究竟做错了什么?
Thanks for help!感谢帮助!
So near.这么近。 That second bit is just missing data.
第二位只是缺少数据。 So it should be:
所以应该是:
resource "local_file" "app_cert" {
content = "${data.openstack_compute_keypair_v2.app_public_key.public_key}"
filename = "${path.module}/app.cert"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.