<p>I am looking for a recipe using Terraform to create a Kubernetes cluster on AWS using Fargate.  I cannot find any end-to-end documentation to do this.</p>
<p>I am using SSO, and so terraform needs to use my AWS credentials to do this.</p>
<p>No example I can find addresses using AWS credentials and Fargate.</p>
<p>If anyone has done this and has a recipe for all of the above, please share.</p>

user10664542
<p>You can use popular module for that <a href="https://github.com/terraform-aws-modules/terraform-aws-eks" rel="nofollow noreferrer">
terraform-aws-eks</a>. It supports Fargate EKS as well. Since its open sourced, you can also have a look at exactly how to create such clusters if you want to fork and customize the module, or create your own scratch.</p>
<p>Example use for Fargate EKS from its docs:</p>
<pre><code>module &quot;eks&quot; {
  source          = &quot;../..&quot;
  cluster_name    = local.cluster_name
  cluster_version = &quot;1.17&quot;
  subnets         = module.vpc.private_subnets

  tags = {
    Environment = &quot;test&quot;
    GithubRepo  = &quot;terraform-aws-eks&quot;
    GithubOrg   = &quot;terraform-aws-modules&quot;
  }

  vpc_id = module.vpc.vpc_id

  fargate_profiles = {
    example = {
      namespace = &quot;default&quot;

      # Kubernetes labels for selection
      # labels = {
      #   Environment = &quot;test&quot;
      #   GithubRepo  = &quot;terraform-aws-eks&quot;
      #   GithubOrg   = &quot;terraform-aws-modules&quot;
      # }

      # using specific subnets instead of all the ones configured in eks
      # subnets = [&quot;subnet-0ca3e3d1234a56c78&quot;]

      tags = {
        Owner = &quot;test&quot;
      }
    }
  }

  map_roles    = var.map_roles
  map_users    = var.map_users
  map_accounts = var.map_accounts
}
</code></pre>
