AWS Code Commit
AWS CodeCommit - 基礎用法
AWS CodeCommit 是完全託管的原始碼控制服務,可託管安全的 Git 儲存庫,相當於一個Private GitHub。它可讓團隊在安全且高度可擴充套件的生態系統中輕鬆協作處理程式碼。使用 CodeCommit,無需執行自己的原始碼控制系統,也無需擔心基礎設施的擴充套件能力。可以使用 CodeCommit 將來自原始碼的任何資料安全儲存為二進位制檔案,而且它可以無縫相容您現有的 Git 工具。
下面,我們一起探索一下CodeCommit的基本用法,來實現你的第一個Commit。
1. Create an AWS CodeCommit Repository
Create in the AWS Console:
Service Menu -> CodeCommit -> Create repository
On the Create repository page, configure:
- Name: My-Repo
- Description: My first repository
- Click Create
An empty repo called My-Repo will be created in CodeCommit. Connection details will be shown.
2. Create an EC2 Instance
Create an EC2 instance in the AWS Console, and record down the public IP address.
3. Connect the CodeCommit to the EC2 instance
通常有兩種方式:
- SSH keys for AWS CodeCommit
- HTTPS Git credentials for AWS CodeCommit
這裡,我們使用 SSH keys for AWS CodeCommit
Before this step, you need to create a Key pair for authentication. Say the name is “KEYPAIR.pem”.
Save the .pem file to your local computer.
- chmod command: change the access permissions of file system objects
- ssh command: can ssh to the EC2 public IP
chmod 400 KEYPAIR.pem
ssh -i KEYPAIR.pem ec2-user@EC2PublicIP
chmod 400 qwikLABS-L2990-19969242.pem
ssh -i qwikLABS-L2990-19969242.pem ec2-user@3.230.119.106
- Type yes when prompted to allow a first connection to this remote SSH server.
- Because you are using a key pair for authentication, you will not be prompted for a password.
4. In the EC2, create a Local Repo using Git
- Install the git client:
sudo yum install -y git
- Use the Git credentials helper with the AWS credentials profile, and enables the Git credentials helper to send the path to repositories.
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
- You will now need to obtain the HTTPS URL of your AWS CodeCommit repository.
- In the AWS CodeCommit Management Console, click the Clone URL then click Clone HTTPS
- The URL look similar to below:
https://git-codecommit.us-east-1.amazonaws.com/v1/repos/My-Repo - In the remote SSH session, copy and paste: git clone URL(Replace the URL with the CodeCommit clone URL), and run the command
- You should see the following message:
Cloning in to ‘my-demo-repo’…
Warning: You appear to have cloned an empty repository.
5. Make a Code Change in the EC2, and Commit to the Repo
To create your first commit in your local repo.
- Use the following command to create two files with content in your local repo:
cd ~/My-Repo
echo "The domestic cat (Felis catus or Felis silvestris catus) is a small, usually furry, domesticated, and carnivorous mammal." >cat.txt
echo "The domestic dog (Canis lupus familiaris) is a canid that is known as man's best friend." >dog.txt
- List the directory to see the files were created
ls
- Run this command to stage the change in your local repo:
git add cat.txt dog.txt
- View the status of your repo:
git status
You will see the two files are ready to be committed to the repo.
- Run the command to commit the change in your local repo:
git commit -m "Added cat.txt and dog.txt"
- View the details about the commit you just made:
git log
6. Push your first Commit
- Push the commit from your local repo to your AWS CodeCommit Repository.
git push -u origin master
Once you pushed code to the AWS CodeComit repo, you can view the contents using the AWS CodeCommit console.
- In the CodeCommit Management Console, ensure you are in the My-Repo repo.
- Refresh your screen. The two files that you added to your repo should be displayed.
- Click each file to view the contents.
Congratulations! You have created an AWS CodeCommit repo and can now consider how to bring its features and capabilities to your development workflow. These include:
- Collaboration
- Encryption
- Access Control
- High Availability and Durability
- Unlimited Repositories
- Easy Access and Integration
相關文章
- [原創] How to pull code when shared repo commit history has been changedMIT
- git commit後如何取消commitGitMIT
- Git commit 之後,想撤銷 commitGitMIT
- git commit 彈出編輯器後報錯: Aborting commit due to empty commit message.GitMIT
- AWS Switching to an IAM role (AWS CLI)
- git commit --amendGitMIT
- Commit規範MIT
- AWS 高可用AWS架構方案架構
- 關於Git commitGitMIT
- Git拆分commit提交GitMIT
- git commit 規範GitMIT
- Git commit規範GitMIT
- Container on AWSAI
- AWS - [01]
- python中的一個現象,db.commit和db.commit()PythonMIT
- 撤銷 git commit --amendGitMIT
- Git Commit 標準化GitMIT
- git修改commit註釋GitMIT
- Git插入新的commitGitMIT
- Git刪除指定commitGitMIT
- Git commit message 規範GitMIT
- git 修改 commit 資訊GitMIT
- 撤銷 git commit –amendGitMIT
- ordered_commit流程梳理MIT
- Async Commit 原理介紹MIT
- 如何修改git commit message?GitMIT
- AWS學習
- AWS Certified DevOps Engineer Professional vs AWS Certified Solutions Architect Professionaldev
- 132 SVN提交報錯"Commit blocked by pre-commit hook"的解決辦法MITBloCHook
- Git 合併指定的commitGitMIT
- git commit提交空內容GitMIT
- Git修改commit提交資訊GitMIT
- [Git CLion] 規範Commit格式GitMIT
- git hooks之——pre-commitGitHookMIT
- innodb_flush_log_at_trx_commitMIT
- 規範你的commit msgMIT
- 規範你的 commit message 並且根據 commit 自動生成 CHANGELOG.mdMIT
- Udemy AWS SAA - RDS