AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 118

A company uses AWS CodeCommit for source code control. Developers apply their changes to various feature branches and create pull requests to move those changes to the main branch when the changes are ready for production.

The developers should not be able to push changes directly to the main branch. The company applied the AWSCodeCommitPowerUser managed policy to the developers’ IAM role, and now these developers can push changes to the main branch directly on every repository in the AWS account.

What should the company do to restrict the developers’ ability to push changes to the main branch directly?

Answer options

Correct answer: A

Explanation

The correct answer is A because creating an additional policy with a Deny rule specifically targeting the GitPush and PutFile actions for the main branch effectively prevents developers from pushing changes directly to it. Option B fails as it removes necessary permissions, and Option C does not create an additional policy, which may not be adequate for existing permissions. Option D incorrectly allows pushing to feature branches instead of restricting the main branch.