title: How to create and assume an IAM role with terraform in the same plan
body: <p>Is there a trick to both create and assume an IAM role in the same terraform plan?</p>
  
  <p>I am trying to use terraform to create EKS clusters by assuming a role that is created as part of the job. <a href="https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html" rel="nofollow noreferrer">AWS assigns the identity</a> that creates the cluster as the admin (system:master).  I'd like to have a new role created and assigned for each cluster, but it seems to cause issues with Terraform's plan.  The only part of the job that needs to assume the role is the cluster creation step.</p>
  
  <p>So far I've worked around the issue with <a href="https://www.hashicorp.com/blog/resource-targeting-in-terraform" rel="nofollow noreferrer">resource targeting</a>, which uses a separate step to target creation of the admin role before running the complete plan.  However, it would be nice if I didn't need multiple steps to create the cluster.</p>
  
  <p>I'm somewhat new to Terraform, so I'm wondering if I'm overlooking something.</p>