Raf*_*ael 0 terraform terraform-provider-gcp
resource "google_service_account" "myaccount" {
account_id = "dev-foo-account"
}
resource "google_service_account_key" "mykey" {
service_account_id = google_service_account.myaccount.name
}
data "google_service_account_key" "mykey" {
name = google_service_account_key.mykey.name
public_key_type = "TYPE_X509_PEM_FILE"
}
Run Code Online (Sandbox Code Playgroud)
如果我创建一个服务帐户和这样的密钥 - 之后如何获取密钥?
terraform output产量:
$ terraform output -json google_service_account_key
The output variable requested could not be found in the state
file. If you recently added this to your configuration, be
sure to run `terraform apply`, since the state won't be updated
with new output variables until that command is run.
Run Code Online (Sandbox Code Playgroud)
如果您想在应用计划后使用该变量,则必须将该变量作为输出:
output "my_private_key" {
value = data.google_service_account_key.mykey.private_key
}
Run Code Online (Sandbox Code Playgroud)
输出“my_private_key”的值:
$ terraform output my_private_key
Run Code Online (Sandbox Code Playgroud)
要获取 JSON 格式的凭证,稍后可用于身份验证:
$ terraform output -raw key | base64 -d -
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2351 次 |
| 最近记录: |