1.6.18.7.1. show
terraform state show命令可以展示状态文件中单个资源的属性。
1.6.18.7.1.1.1. 用法
terraform state show [options] ADDRESS
该命令需要指定一个资源地址。
该命令支持以下可选参数:
- -state=path:指向状态文件的路径。默认情况下使用"terraform.tfstate"。如果启用了远程Backend则该参数设置无效
terraform state show的输出被设计成人类可读而非机器可读。如果想要从输出中提取数据,请使用terraform show -json。
1.6.18.7.1.1.2. 展示单个资源
$ terraform state show 'packet_device.worker'
# packet_device.worker:
resource "packet_device" "worker" {
billing_cycle = "hourly"
created = "2015-12-17T00:06:56Z"
facility = "ewr1"
hostname = "prod-xyz01"
id = "6015bg2b-b8c4-4925-aad2-f0671d5d3b13"
locked = false
}
1.6.18.7.1.1.3. 展示单个模块资源
$ terraform state show 'module.foo.packet_device.worker'
1.6.18.7.1.1.4. 展示声明count资源中特定实例
$ terraform state show 'packet_device.worker[0]'
1.6.18.7.1.1.5. 展示声明for_each资源中特定实例
Linux, MacOS, and Unix:
$ terraform state show 'packet_device.worker["example"]'
PowerShell:
$ terraform state show 'packet_device.worker[\"example\"]'
Windows命令行:
$ terraform state show packet_device.worker[\"example\"]