[AWS] Lab: Configure and Work with CodeCommit from the CLI
Introduction
In this hands-on lab, we go through the process of configuring a CodeCommit repository from the AWS Command Line Interface. We also go through some key prerequisite steps, such as installing Git, configuring HTTPS credentials, and preparing the environment to work with Git and CodeCommit. This lab covers the steps that need to be taken anytime you work with CodeCommit from the CLI.
Solution
Log in to the live AWS environment using the credentials provided. Make sure you're in the N. Virginia (us-east-1
) region throughout the lab.
Create a Server from an Amazon Linux 2 AMI
- Navigate to the EC2 dashboard, and click Launch Instance.
- On the AMI page, select the Amazon Linux 2 AMI.
- Leave t2.micro selected, and click Next: Configure Instance Details.
- On the Configure Instance Details page:
- Network: Leave default
- Subnet: Select one provided
- Auto-assign Public IP: Enable
- Click Review and Launch > Launch.
- In the key pair dialog, select Create a new key pair.
- Give it a Key pair name of "confighttps".
- Click Download Key Pair, and then Launch Instances.
- Click View Instances, and give it a few minutes to enter the running state.
Install Git and Create IAM CodeCommit Credentials
- Select the newly created instance.
- Click Connect at the top of the screen.
- Open a terminal window and navigate to the folder for your downloads.
-
Linux/Mac users: Execute the following command:
chmod 400 confighttps.pem
-
Linux/Mac users: Run the example SSH command from the Connect window in the AWS Management Console in your terminal application.
Note: If you are using Windows/PuTTY, use the link in the Connect window in the AWS Management Console for Connect using PuTTY and follow those instructions to connect.
-
In the terminal, run the following command:
sudo yum update -y
-
In the AWS Management Console, navigate to IAM > Users.
- Click on cloud_user.
- Click Add permissions > Attach existing policies directly.
- Type "AWSCodeCommit" in the filter search box.
- Select the
AWSCodeCommitFullAccess
policy. -
Click Cancel.
Note: We were just showing how to create this, but the permissions already exist in this lab.
-
In the terminal, run the following command to install Git:
sudo yum install git -y
-
In the AWS Management Console, with
cloud_user
opened, click the Security credentials tab. - Navigate to the bottom of the screen, and click Generate under HTTPS Git credentials for AWS CodeCommit.
- Click Download credentials > Close.
Create IAM User Access Key and CodeCommit Repository
- Click Create access key.
-
Click Download .csv file.
Note: The access keys will be used for the AWS Command Line Interface access in our lab. Generally, you would use an IAM role attached to the instance in production environments. The HTTPS Git credentials for AWS CodeCommit will provide access to CodeCommit.
-
Open the terminal window.
-
Configure the AWS CLI credentials:
aws configure
-
Enter the AWS
Access Key
andSecret Access Key
from the file downloaded in the previous step when prompted to do so. - Enter
us-east-1
as the region. - Hit Enter to accept the
Default output format
. -
Run the following command to create a CodeCommit repository from the AWS CLI:
aws codecommit create-repository --repository-name RepoFromCLI --repository-description "My demonstration repository"
-
In the AWS Management Console, open CodeCommit and refresh the screen.
- Click on the RepoFromCLI repository link to open it.
- Click Add file > Upload file.
- Click Choose file.
- Select any small file from your machine you don't mind uploading.
- Enter your name as the author name and your email as the email address.
- Click Commit changes.
- Click Clone URL > Clone HTTPS.
- Open up your terminal window.
-
Run the following command to clone the repository to the server:
git clone [paste the URL from the clipboard]
-
Enter the Git credentials username from the file downloaded earlier for the username prompt.
- Enter the Git credentials password from the file downloaded earlier for the password prompt.
-
Run the following commands:
ls cd RepoFromCLI ls
-
Run the following command to create a local text file:
vim test.txt
-
Hit
i
to enter insert mode and type the text:This is just a test of working with CodeCommit from the CLI
-
Hit the Escape key, type
:wq!
, and press Enter. -
Add the file to Git:
git add test.txt
-
Commit the file to the local repository:
git commit -m "added test.txt"
-
Verify the file was committed:
git log
-
Push the change to the CodeCommit repository:
git push -u origin main
-
Enter the Git credentials username from the file downloaded earlier for the username prompt.
- Enter the Git credentials password from the file downloaded earlier for the password prompt.
- Refresh the AWS Management Console view of the CodeCommit repository for RepoFromCLI and verify the new file was uploaded.
相关文章
- 使用QuTrunk+AWS ParallelCluster3进行并行计算
- 如何使用YATAS审查AWS基础设施中潜在的安全问题
- 【Vue-Spring跨域Bug已解决】has been blocked by CORS policy: The value of the······
- ORA-01378: The logical block size (string) of file string is not compatible with the disk sector size (media sector size is string and host sector size is string) ORACLE 报错 故障修复 远程处理
- ORA-26747: The one-to-many transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-28074: The “string” field of the redaction parameters is not valid. ORACLE 报错 故障修复 远程处理
- ORA-46013: The value of the “aclDirectory” element is too long. ORACLE 报错 故障修复 远程处理
- ORA-48409: The ADR homes exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-48928: The predicate exceeds the max limit string ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-011439; Symbol: ER_KEYRING_AWS_FAILED_TO_ENCRYPT_KEY; SQLSTATE: HY000 报错 故障修复 远程处理
- AWS 宣布赞助 Rust 语言
- 亚马逊AWS S3故障4小时,波及 Adobe、Slack 等数千家线上服务
- 界面上的文字表达技巧(The Language of the Interface)
- 破除对 AWS Fargate 的幻觉
- 如何评价 MXNet 被亚马逊AWS 选为官方深度学习平台
- 使用甲骨文云服务半年后,AWS宣布其仍是Zoom的首选云服务商
- 行界面并掌握常用命令Note: The original prompt mentions 25character title but the provided Chinese alternative mentions 25word title. This response assumes the latter is the intended instruction.(怎样进入linux命令)
- Discover the Power of Linux with YLMF: The UserFriendly Operating System(linuxylmf)
- AWS改变MySQL配置,创建更加美好的未来(aws改mysql配置)
- AWS MySQL服务价格深度剖析(aws mysql 价格)
- 亚马逊AWS获得美国国家安全局百亿美元云计算合同