aws ec2 describe-instances --output json > ec2.json
cat ec2.json | jq -r '
  [
    "实例id","服务器名称","内网ip","公网ip","操作系统","服务器开关机状态"
  ],
  (
    .Reservations[].Instances[] | [
      .InstanceId,
      (
        (.Tags[]? | select(.Key=="Name") | .Value) // ""
      ),
      (.PrivateIpAddress // ""),
      (.PublicIpAddress // ""),
      (
        .PlatformDetails // .Platform // "Linux/UNIX"
      ),
      (.State.Name // "")
    ]
  ) | @csv
' > ec2_list.csv

| 实例id | 服务器名称 | 内网ip | 公网ip | 操作系统 | 服务器开关机状态 |
|-----------|------------|-------------|-------------|---------------|------------------|
| i-xxxxxxx | app-server | 10.0.1.10 | 54.1.2.3 | Windows | running |
| i-yyyyyyy | db-server | 10.0.1.11 | | Linux/UNIX | stopped |