@terraform Connector¶
Generate one or more SSH hosts from a Terraform output variable. The variable must be a list of hostnames or dictionaries.
Output is fetched from a flattened JSON dictionary output from terraform output
-json. For example the following object:
{
  "server_group": {
    "value": {
      "server_group_node_ips": [
        "1.2.3.4",
        "1.2.3.5",
        "1.2.3.6"
      ]
    }
  }
}
The IP list server_group_node_ips would be used like so:
pyinfra @terraform/server_group.value.server_group_node_ips ...
You can also specify dictionaries to include extra data with hosts:
{
  "server_group": {
    "value": {
      "server_group_node_ips": [
        {
            "ssh_hostname": "1.2.3.4",
            "ssh_user": "ssh-user"
        },
        {
            "ssh_hostname": "1.2.3.5",
            "ssh_user": "ssh-user"
        }
      ]
    }
  }
}
Usage¶
pyinfra @terraform/name ...
            pyinfra next