我正在执行 GCP 模块来创建服务帐户。
主文件:
resource "google_service_account" "gsvc_account" {
account_id = "xxx"
display_name = ""
project = "proj-yyy"
}
output "account_id" {
value = "${google_service_account.gsvc_account.account_id}"
}
创建帐户后,将创建一个terraform.tfstate
包含帐户所有详细信息的文件。
terraform.tfstate
{
"version": 4,
"terraform_version": "0.12.0",
"serial": 3,
"lineage": "aaaa-bbbb-cccc",
"outputs": {
"xxx": {
"value": "xxx",
"type": "string"
}
},
"resources": [
{
"module": "module.gsvc_tf",
"mode": "managed",
"type": "google_service_account",
"name": "gsvc_account",
"provider": "provider.google",
"instances": [
{
"schema_version": 0,
"attributes": {
"account_id": "xxx",
"display_name": "",
"email": "xxx@yyy.com",
"id": "projects/proj-yyy/serviceAccounts/xxx@yyy.com",
"name": "projects/proj-yyy/serviceAccounts/xxx@yyy.com",
"policy_data": null,
"project": "proj-xxx",
"unique_id": "10891885"
}
}
]
}
]
}
正如您在上面看到的,在模块中,我正在输出account_id
输入变量。有没有办法输出attributes
可视化。id
等name
,以便它们可以被另一个模块访问?在attributes
创建资源后计算。