terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
  backend "s3" {}
}
variable "account" {
  type = string
}
variable "role_name" {
  type = string
  default = "full-manager-eks-role"
}
provider "aws" {
  region  = "us-west-2"
  profile = var.account
}

resource "aws_iam_role" "eks-service-role" {
  name = var.role_name

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect = "Allow"
        Principal = {
          Service = "eks.amazonaws.com"
        }
        Action = "sts:AssumeRole"
      }
    ]
  })
  managed_policy_arns = ["arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"]
}

output "role_arn" {
  value = aws_iam_role.eks-service-role.arn
}
