Create service role for CodeBuild service

Create service role for CodeBuild service

  1. CodeBuild needs IAM roles to build docker, push image, and interact with the EKS cluster using the kubectl command.
  • Let’s create the eks-CodeBuildServiceRole roles and add inline policy from the VS Code terminal
wget https://raw.githubusercontent.com/First-Cloud-Journey/000062-EKSCICD/main/codebuild/cbAssumeRolePolicyDocument.json
aws iam create-role --role-name eks-CodeBuildServiceRole --assume-role-policy-document file://cbAssumeRolePolicyDocument.json
wget https://raw.githubusercontent.com/First-Cloud-Journey/000062-EKSCICD/main/codebuild/cbPolicyDocument.json
aws iam put-role-policy --role-name eks-CodeBuildServiceRole --policy-name codebuild-access --policy-document file://cbPolicyDocument.json

Create Code Build Service Role

  1. To verify the created roles, we do the following:
  • Access the AWS Console interface

  • Search for IAM

  • Select IAM

Create Code Build Service Role

  1. In the IAM interface
  • Select Roles
  • Search for eks-Code
  • View the 2 newly created Roles

Create Code Build Service Role