Why is it problematic to configure a provider with attributes of resources created in the same configuration?
AdvancedConceptProviders, Resources and Data Sources
Answer
Terraform needs provider configuration before it can plan resources of that provider. If you feed the Kubernetes or Helm provider from an EKS cluster created in the same apply, the first plan sees unknown values and can fail, or fails on destroy because the cluster disappears before its resources are removed. The fix is separate states (cluster layer, then add-ons layer) or a data source on an already-existing cluster.
More on Providers, Resources and Data Sources
What is a resource block and how is it addressed?BeginnerWhat is the difference between a resource and a data source?BeginnerHow do you configure a provider such as AWS?BeginnerHow do you use the same provider with multiple regions or accounts?IntermediateIn what order does the AWS provider look for credentials?IntermediateWhat does `default_tags` in the AWS provider do and what are its pitfalls?Intermediate