What does "eksctl create iamserviceaccount" do under the hood on an EKS cluster? AWS supports IAM Roles for Service Accounts (IRSA) that allows cluster operators to map AWS IAM Roles to Kubernetes Service Accounts.
To do so, one has to create an iamserviceaccount in an EKS cluster:
eksctl create iamserviceaccount \
    --name &lt;AUTOSCALER_NAME&gt; \
    --namespace kube-system \
    --cluster &lt;CLUSTER_NAME&gt; \
    --attach-policy-arn &lt;POLICY_ARN&gt; \
    --approve \
    --override-existing-serviceaccounts

The problem is that I don't want to use the above eksctl command because I want to declare my infrastructure using terraform.
Does eksctl command do anything other than creating a service account? If it only creates a service account, what is the YAML representation of it?
Yes It does more than just creating a service account. It does three things:

It Creates an IAM role.
It attaches the desired iam-policy (--attach-policy-arn
&lt;POLICY_ARN&gt;) to the created IAM role.
It creates a new kubernetes service account annotated with the arn of the created IAM role.

Now It's easy to declare the above steps using kubernetes and aws providers in terraform.