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.
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.
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.
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.
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
and Secret Access Key
from the file downloaded in the previous step when prompted to do so.
us-east-1
as the region.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.
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.
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.
[AWS] Lab: Configure and Work with CodeCommit from the CLI
原文:https://www.cnblogs.com/Answer1215/p/14616509.html