How to dynamically define multiple provisioner "remote-exec"

I use terraform to create a cluster through rke. Now I want to execute a command on each created node. It looks like:
resource “rancher2_cluster” “cluster_name” {
xxx

provisioner “remote-exec” {
xxx
}

provisioner “remote-exec” {
xxx
}

}

If I don’t know in advance how many nodes will be created, how to dynamically define multiple provisioners? Thanks Reply.

Hi @wangfx111,

There is no mechanism for dynamically configuring provisioners in Terraform. Provisioners are a feature of last resort, so their functionality is limited.

If you can say more about the underlying problem you’re trying to solve, I or another community member may be able to suggest other ways to solve it that don’t involve provisioners at all, or that at least don’t require dynamic provisioner configuration.