Configure RBAC

Configure RBAC

  1. For CodeBuild to be able to interact with EKS, we will modify the aws-auth configMap
  • From the VS Code terminal where you have connected to the EKS cluster, get a copy of the aws-auth configMap using the command:
kubectl get configmaps aws-auth -n kube-system -o yaml > aws-auth.yaml

RBAC

  1. Open the aws-auth.yaml file just created above, it will have the following content:
apiVersion: v1
data:
  mapRoles: |
    - rolearn: arn:aws:iam::119640367180:role/eksctl-k8s-demo-nodegroup-k8s-demo-NodeInstanceRole-Fi9fWfTCOp7X
      groups:
      - system:bootstrappers
      - system:nodes
      username: system:node:{{EC2PrivateDNSName}}
kind: ConfigMap
metadata:
  creationTimestamp: "2026-09-28T11:10:50Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:mapRoles: {}
    manager: Kubernetes Java Client
    operation: Update
    time: "2026-09-28T11:10:50Z"
  name: aws-auth
  namespace: kube-system
  resourceVersion: "1131"
  uid: 07835058-597f-4bed-ac03-2768d80e4cb3

RBAC

  1. Modify this aws-auth.yaml file, add an item in the data.mapRoles array:
    - rolearn: arn:aws:iam::${AWS_ACCOUNT_ID}:role/eks-CodeBuildServiceRole
      groups:
      - system:masters
      username: codebuild-eks
  1. The aws-auth.yaml file after adding the eks-CodeBuildServiceRole role looks like this:

Important Note:

  • You must delete the creationTimestamp, resourceVersion and uid lines in the metadata section to avoid errors when applying the file. The sample code below has these lines already removed.
apiVersion: v1
data:
  mapRoles: |
    - rolearn: arn:aws:iam::119640367180:role/eksctl-k8s-demo-nodegroup-k8s-demo-NodeInstanceRole-Fi9fWfTCOp7X
      groups:
      - system:bootstrappers
      - system:nodes
      username: system:node:{{EC2PrivateDNSName}}
    - rolearn: arn:aws:iam::119640367180:role/eks-CodeBuildServiceRole
      groups:
      - system:masters
      username: codebuild-eks
kind: ConfigMap
metadata:
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:mapRoles: {}
    manager: Kubernetes Java Client
    operation: Update
    time: "2026-09-28T11:10:50Z"
  name: aws-auth
  namespace: kube-system

RBAC

  1. Apply the modified aws-auth.yaml file from the terminal:
kubectl apply -f aws-auth.yaml

RBAC