Configure Permissions and IAM Role

Configure Sudo Permissions for GitLab Runner

GitLab Runner needs sudo privileges to execute CI/CD tasks such as build, test, and deploy. This section will guide you through configuring sudo permissions for GitLab Runner.

  1. Open Sudo Configuration File Visudo Command

Execute the command:

sudo visudo
  1. Update Sudo Permissions Update Sudo

Add the following line to the file:

gitlab-runner ALL=(ALL) NOPASSWD:ALL

After adding, press Ctrl + X to exit, Y to confirm saving, and Enter to complete.

Configure IAM Role

  1. Access EC2 Instance EC2 Access

Steps to follow:

  • Open EC2 Console
  • Select the running instance
  • Go to Security tab
  • Choose Modify IAM role
  1. Check Current Role Check Role

Verify that the CustomRWECRRole IAM Role is assigned to the EC2.

  1. Access IAM Role Access IAM

Navigate in IAM Console:

  • Select Roles tab
  • Find CustomRWECRRole
  • Click on the role to view details
  1. Add Policy Add Policy

Add new permissions:

  • Policy to add: AmazonEC2FullAccess
  • Attach to CustomRWECRRole

Assigning AmazonEC2FullAccess should be carefully considered in a production environment. Follow the principle of least privilege and only grant necessary permissions.