- AWS Automation Cookbook
- Nikit Swaraj
- 274字
- 2021-07-02 23:00:40
How to do it...
Let's get started with that, and perform the following operations:
- First of all, let's create a custom policy where we will give the restriction definition.
- Go to IAM Console and click on the Policies section. Then, click on Create Policy:
- Click on Create Your Own Policy:

- You will be redirected to another page where you have to fill in the Policy Name, a description of the policy, and a policy document. The policy document will be the definition, where we will mention the resources and actions:

- Insert the following policy definition (x60xxxxxxx39 will be basically your account ID):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:GitPull",
"codecommit:GitPush"
],
"Resource": "arn:aws:codecommit:us-east-1:x60xxxxxxx39:HelloWorld"
}
]
}
- Click on Create Policy; then we will have our own custom policy:
- Now, let's remove the AWSCodeCommitPowerUser access from the IAM user that we created to clone the repository by clicking on x:

- Click on Add permissions, after that click on Attach Existing Policies Directly and search for Policy name in filter, check that, and save it:
- We will have a user with only our custom policy, which means the user will only have access to the HelloWorld repository and only two actions, git push and git clone:
awsstar@awsstar:~$ aws codecommit list-repositories
An error occurred (AccessDeniedException) when calling the ListRepositories operation: User: arn:aws:iam::16xxxxxx139:user/awsccuser is not authorized to perform: codecommit:ListRepositories
The preceding command output shows AccessDeniedException, that is, awsccuser is not authorized to perform codecommit:ListRepositories. The reason for this is we have given access to only two operations or actions: git push and git clone.
推薦閱讀
- Word 2003、Excel 2003、PowerPoint 2003上機(jī)指導(dǎo)與練習(xí)
- Canvas LMS Course Design
- 火格局的時空變異及其在電網(wǎng)防火中的應(yīng)用
- 數(shù)控銑削(加工中心)編程與加工
- Matplotlib 3.0 Cookbook
- 精通Excel VBA
- Maya 2012從入門到精通
- Windows環(huán)境下32位匯編語言程序設(shè)計(jì)
- 塊數(shù)據(jù)5.0:數(shù)據(jù)社會學(xué)的理論與方法
- Hadoop應(yīng)用開發(fā)基礎(chǔ)
- 單片機(jī)技能與實(shí)訓(xùn)
- MATLAB-Simulink系統(tǒng)仿真超級學(xué)習(xí)手冊
- Mastering Ansible(Second Edition)
- 手把手教你學(xué)Photoshop CS3
- 西門子S7-1200/1500 PLC從入門到精通