zoukankan      html  css  js  c++  java
  • [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

    1. Navigate to the EC2 dashboard, and click Launch Instance.
    2. On the AMI page, select the Amazon Linux 2 AMI.
    3. Leave t2.micro selected, and click Next: Configure Instance Details.
    4. On the Configure Instance Details page:
      • Network: Leave default
      • Subnet: Select one provided
      • Auto-assign Public IP: Enable
    5. Click Review and Launch > Launch.
    6. In the key pair dialog, select Create a new key pair.
    7. Give it a Key pair name of "confighttps".
    8. Click Download Key Pair, and then Launch Instances.
    9. Click View Instances, and give it a few minutes to enter the running state.

    Install Git and Create IAM CodeCommit Credentials

    1. Select the newly created instance.
    2. Click Connect at the top of the screen.
    3. Open a terminal window and navigate to the folder for your downloads.
    4. Linux/Mac users: Execute the following command:

      chmod 400 confighttps.pem
    5. 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.

    6. In the terminal, run the following command:

      sudo yum update -y
    7. In the AWS Management Console, navigate to IAM > Users.

    8. Click on cloud_user.
    9. Click Add permissions > Attach existing policies directly.
    10. Type "AWSCodeCommit" in the filter search box.
    11. Select the AWSCodeCommitFullAccess policy.
    12. Click Cancel.

      Note: We were just showing how to create this, but the permissions already exist in this lab.

    13. In the terminal, run the following command to install Git:

      sudo yum install git -y
    14. In the AWS Management Console, with cloud_user opened, click the Security credentials tab.

    15. Navigate to the bottom of the screen, and click Generate under HTTPS Git credentials for AWS CodeCommit.
    16. Click Download credentials > Close.

    Create IAM User Access Key and CodeCommit Repository

    1. Click Create access key.
    2. 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.

    3. Open the terminal window.

    4. Configure the AWS CLI credentials:

      aws configure
    5. Enter the AWS Access Key and Secret Access Key from the file downloaded in the previous step when prompted to do so.

    6. Enter us-east-1 as the region.
    7. Hit Enter to accept the Default output format.
    8. 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"
    9. In the AWS Management Console, open CodeCommit and refresh the screen.

    10. Click on the RepoFromCLI repository link to open it.
    11. Click Add file > Upload file.
    12. Click Choose file.
    13. Select any small file from your machine you don't mind uploading.
    14. Enter your name as the author name and your email as the email address.
    15. Click Commit changes.
    16. Click Clone URL > Clone HTTPS.
    17. Open up your terminal window.
    18. Run the following command to clone the repository to the server:

      git clone [paste the URL from the clipboard]
    19. Enter the Git credentials username from the file downloaded earlier for the username prompt.

    20. Enter the Git credentials password from the file downloaded earlier for the password prompt.
    21. Run the following commands:

      ls
      cd RepoFromCLI
      ls
    22. Run the following command to create a local text file:

      vim test.txt
    23. Hit i to enter insert mode and type the text:

      This is just a test of working with CodeCommit from the CLI
    24. Hit the Escape key, type :wq!, and press Enter.

    25. Add the file to Git:

      git add test.txt
    26. Commit the file to the local repository:

      git commit -m "added test.txt"
    27. Verify the file was committed:

      git log
    28. Push the change to the CodeCommit repository:

      git push -u origin main
    29. Enter the Git credentials username from the file downloaded earlier for the username prompt.

    30. Enter the Git credentials password from the file downloaded earlier for the password prompt.
    31. Refresh the AWS Management Console view of the CodeCommit repository for RepoFromCLI and verify the new file was uploaded.
  • 相关阅读:
    小、快、简、易、强的“银弹”— fastm
    使用Creative suite 3和Flex Builder3实现Flex 3的换肤
    Apache HTTP Server 与 Tomcat 的三种连接方式介绍
    iframe自动适应付窗口的大小变换
    Flash网络游戏开发入门经验共享
    比较详细的 Linux Top 命令解析
    HttpContext是干什么的
    asp.net,cookie,写cookie,取cookie 的方法
    为什么我们不要 .NET 程序员
    在Ubuntu上安装使用深度影音&深度音乐(推荐)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14616509.html
Copyright © 2011-2022 走看看