AWS Certified DevOps Engineer – Professional — Question 129
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
- A. Create an additional policy to include a Deny rule for the GitPush and PutFile actions. Include a restriction for the specific repositories in the policy statement with a condition that references the main branch.
- B. Remove the IAM policy, and add an AWSCodeCommitReadOnly managed policy. Add an Allow rule for the GitPush and PutFile actions for the specific repositories in the policy statement with a condition that references the main branch.
- C. Modify the IAM policy. Include a Deny rule for the GitPush and PutFile actions for the specific repositories in the policy statement with a condition that references the main branch.
- D. Create an additional policy to include an Allow rule for the GitPush and PutFile actions. Include a restriction for the specific repositories in the policy statement with a condition that references the feature branches.
Correct answer: A
Explanation
The correct answer is A because creating an additional policy with a Deny rule specifically for the GitPush and PutFile actions on the main branch effectively prevents developers from pushing changes directly to it. Option B is incorrect as removing the IAM policy and applying a read-only policy would not allow any pushes at all. Option C is not correct because altering the existing policy does not provide the necessary separation and specificity needed to restrict access. Option D is also wrong as allowing actions on feature branches does not address the main branch restriction.