This is a really neat hack that I didnt’ know about.
There is a challenge when using a terraform provider which needs information from the terraform state in order to be configured. The canonical example is creating a kubernetes cluster and using it in the same terraform component.
The kubernetes provider needs authentication details that can only be known after the cluster is created. This is a problem, because Terraform will try and configure the provider before creating any resources.
That is, unless the provider has an alias
. In that case terraform will not try to configure the provider until it is first used.