A team is developing an application and the code is managed in a repository in AWS CodeCommit.
The developers push code in their own branches.
When the code is ready for release, only a senior team member is allowed to merge the other branches into master.
The merging event then triggers a pipeline for the deployment in production.
You need to make sure that the team members are allowed to push or merge code to all the branches except the master branch.
Which of the following options describes the correct method?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - A.
An IAM policy can be used to limit pushes and merges to a branch in CodeCommit.
Please check the reference in.
https://docs.aws.amazon.com/codecommit/latest/userguide/auth-and-access-control-iam-identity-based-access-control.html#identity-based-policies-example-4.Option A is CORRECT: This IAM policy does not allow the team members to push and merge codes to the master branch.
However operations on other branches are allowed.
Option B is incorrect: In AWS CodeCommit management console, you cannot add team members as viewers or editors.
Option C is incorrect: This IAM policy is incorrect as it does not deny the team members to push/merge codes to the master branch of the repository.
Option D is incorrect: Because CodeCommit does not have a resource policy that you can attach.
The correct method to allow team members to push or merge code to all branches except the master branch, according to the given scenario, is option A: Create an IAM group that includes the team members and attach the below policy:
json{ "Effect": "Allow", "Action": [ "codecommit:GitPush", "codecommit:Merge*" ], "Resource": [ "arn:aws:codecommit:*:*:the-repo-name" ], "Condition": { "StringNotEquals": { "codecommit:References": [ "refs/heads/master" ] } } }
Option A provides an IAM policy that allows team members to perform Git push and merge actions, but only for branches other than master. The policy is attached to an IAM group that includes the team members. Here's a detailed explanation of the policy:
Option B is incorrect because it suggests configuring the team members as viewers in the master branch and editors in the dev branch. This approach does not meet the requirement of allowing team members to push or merge code to all branches except the master branch.
Option C is incorrect because it suggests denying the "codecommit:GitPush" and "codecommit:Merge*" actions for the team members. This would prevent them from pushing or merging code to any branch, including the branches other than the master branch.
Option D is incorrect because it suggests denying the "codecommit:GitPush" and "codecommit:Merge*" actions for the principal (i.e., the IAM group), but it does not specify any condition or resource to limit the denial to the master branch. This would prevent the IAM group from pushing or merging code to any branch of any repository.