Category: AWS

  • How to Solve AWS 253-[LX] Bash Shell Scripting Lab Challenge

    How to Solve AWS 253-[LX] Bash Shell Scripting Lab Challenge

    Are you participating in the AWS ReStart program and looking for solutions to some lab challenges? You are not alone because I participated in the same program and was in the same situation in 2023. Therefore, you have come to the right place. Specifically, in this tutorial, I will help you solve the AWS 253-[LX] Bash Shell Scripting Lab Challenge. Are you ready to be inspired and excited to find a solution? Then, let’s get into the real process of solving the lab challenge.

    The Bash Shell Scripting Lab Challenge Excercise.
    The screenshot was taken by the author, and the content was created by the AWS ReStart Program.

    Before we get our hands dirty in the AWS lab challenge, let me briefly give you the project background so that we are on the same page. First, do you know where the exercise comes from? If you do not know, do not worry, because I will explain it to you. The lab challenge is adapted from the AWS re/Start Program. I participated in it last year. It is a 2–3-month intensive learning and training program in Kenya. Let me take you through a brief description of the program I’m talking about here.

    What is the AWS re/Start Program?

    Before we dive into solving the Bash Shell Scripting Lab Challenge, do you want to become a cloud professional? If you want to start a career within the cloud computing technology sphere but feel you are not qualified for it, then the AWS re/Start program could be perfect for you. By design, it is a rich, immersive, full-time training to become an AWS Cloud Services professional in 2-3 months.

    In other words, it is a 12-week exciting learning journey and skills-rewarding program that a person can experience for free. Nonetheless, it is intended for persons who are either out of work or working in less desired job opportunities, such as military veterans and their families, and youths who want a new beginning in the cloud services job market.

    What makes me say the program is unique?

    What makes AWS re/Start special is that it is very actionable. Informed by scenarios and process labs coursework, you’ll get the foundational knowledge and a stepping stone for an initial position in cloud computing. It is clear that there is a big difference between theory and practice, but what makes AWS re/Start unique is its approach. The used learning models, real-life scenarios, laboratory exercises, and lectures will help you build the knowledge and skills required to perform entry-level cloud roles.

    However, the technical education it provides for its participants is not the only kind of education it offers. They give practical advice on resumes and prepare you for an interview. So, by the end of the program, you will be ready to meet the employers. Therefore, if you’ve considered changing your career track to cloud computing, AWS re/Start can assist you.

    What to expect from the bash shell scripting exercise guide

    In this comprehensive lab guide, I will delve into the AWS challenge lab I solved during my journey, showcasing how AWS re/Start empowered me to embrace the challenge and emerge victorious.

    What is Bash Shell?

    Bash stands for the “Bourne Again Shell.” It is the default shell in the Linux Operating System. Bash Shell gives you an effective and efficient environment for scripting and interacting with your Linux Operating system through commands. It is widely available and used by many developers and organizations.

    Lab Objectives of the bash shell scripting lab challenge exercise

    Based on the lab manual, the challenge had one main lab goal. Therefore, the main goal was to create a directory at the end of the exercise.

    Step-by-step procedure to solve the bash shell scripting exercise

    First, note that the AWS predesigned the lab, and the necessary resources were provisioned and configured. So, according to how the exercise is set, I broke it down into two milestones. Then, the two main steps were divided into different tasks, and each was executed as part of the main project. As a result, the two stages and subtasks enabled me to do it easily. Thus, it will also enable you to achieve the same results easily.

    Step 1 of Solving the Bash Shell Scripting Exercise

    Task 1. Accessing the AWS Management Console

    From the Canvas Instructure homepage, click the modules in the left navigation menu and scroll down to the end of the Linux Module. It should be noted it is the third module after Cloud Foundation. Subsequently, the lab challenge for Bash Shell scripting in this guide is the last one on the module.

    When you click the lab challenge URL, Canvas opens a new page that prompts you to load the tool in a new browser window.

    Next, the lab exercise loads and opens in a new browser window automatically in no time. Subsequently, you should note that the new browser window page has the lab topic at the top.

    • At the top of the instructions, choose the “Start Lab” button on the menu list at the top right.

    At this time, you will notice a start lab panel that opens immediately to show the lab status. First and foremost, you will see that the lab status is “in creation,” as shown in the last statement on the Start Lab panel opened below.

    • Since the lab may take some time to load, wait for it until the “in creation” lab status message changes to display the message that it is ready. Until then, there is no other way to proceed.

    Next, once the status changes to “ready,” close the Start Lab panel by clicking on the X at the top right corner of the panel.

    • Afterward, return to the top of the instructions and select the “AWS” button to open the AWS Management Console. Similarly, the Management Console opens a new browser window next to the lab instructions.

    Additionally, you should notice that the system has automatically logged you into your AWS account. Before accessing the lab resources, you must be registered and recognized as a re/Start program learner.

    Task 2: Separating and pairing the two browser tabs opened in task 1

    Finally, with the two tabs open on the browser, separate them and stack them together so you can simultaneously see the AWS Management Console and the lab challenge instructions tab.

    At this point, you can follow the instructions easily and implement them on the Console.

    Step 2: Use SSH to connect to an Amazon Linux EC2 instance.

    For this lab challenge, AWS has given two main ways to connect to the Amazon Linux EC2 instance based on the operating system a user is using. The first is for Windows users like me, and the second is for Linux macOS users. Nevertheless, each one of them has to underload the access key first.

    Therefore, I downloaded the “. pem” key for Linux users for this lab challenge and used my preinstalled Git Bash Terminal to log in to the system. Git Bash is a command-line interface (CLI) that gives a Microsoft Windows user a friendly environment to interact with a system using CLI. Therefore, I used it to write my commands to interact with the AWS lab environment.

    Task 1 – Windows Users: Using SSH to connect to bash shell scripting lab environment

    The first step is downloading the access key provided for this lab following the procedures below.

    Select “Details” at the top of the instructions and click “Show” on the credentials window presented to you.

    Select the “Download PEM” button and choose where to save your “labsuser.pem” file on your computer. Additionally, make a note of the “PublicIP” address allocated for this lab challenge exercise.

    I am saving the “labsuser.pem” key file. In this tutorial, I saved the key in the downloads folder.

    • Finally, exit by clicking the X on the “Details” panel.

    Task 2: Using Git Bash for Access

    First, open the Git Bash terminal on your computer and type “pwd” to confirm the current working directory.

    Secondly, change the directory to where the key has been stored or downloaded on your hard drive. Use the command: cd”

    Afterward, change the permissions on the key to be read-only by running this command:

    chmod 400 labsuser.pem

    Then, run the following command to log in to the system.

    ssh -i labsuser.pem ec2-user@<public-ip>
    
    Remember: Replace thephrase <public-ip>” with the exact PublicIP address noted in step 2 above.

    Next, when asked, “Are you sure you want to continue connecting?” type “yes” and press enter.

    After pressing enter, you will receive the login successful screen immediately. See the screenshot below.

    In the EC2 Instance, use the “pwd” command to confirm your current working directory. It’s supposed to be “/home/ec2-user

    Configuring the AWS EC2 instance and environment for the lab

    Next, configure the instance for use as follows. The command is “aws configure”

    On the next section that appears, enter the lab details as required. Then, press the enter button after typing the correct lab details for each prompt.

    Remember, as instructed, you copied these details at the beginning of the lab session.

    After configuration, create a new directory using the “mkdir” command. For this tutorial, I made a directory named Lab253 and used the “ls” command to confirm if the directory existed in the EC2 Instance. The screenshot below shows two directories in the instance: companyA and Lab253, which I created previously.

    Next, navigate to the newly created directory using the “cd” command, as shown in the screenshot I captured below.

    After entering the new directory, use the “touch command” to create an empty file (0KB) with an appropriate name that you can easily relate to or remember. Next, open the file using a Linux file editor.

    As you can note in the screenshot below, I created an empty file named Jose1.sh and opened it using the Vim file editor for this tutorial.

    Additionally, the ‘.sh’ file extension means that the file is a bash shell script that should be executed using the bash shell. After running the open command in Vim, the empty file opens. Next, press the letter the “i” button on your keyboard to change the file into insert mode so that you can create your script.

    When the file is in insert mode, create the script prepared per the lab challenge instructions.

    Note: I first prepared the script using a text file for this tutorial. Then, I copied and pasted it into the file opened in the Vim file editor.

    After copying and pasting, press the escape keyboard button ‘esc’ to exit the insert mode in the Vim file editor. Then, type the full colon symbol “:” followed by ‘wq’ at the end of the file, as shown in the screenshot below.

    After that, press enter to save and close the file.

    How to make the bash shell script file automatically executable

    • The next step is to make the file executable every time it is opened and run. Therefore, use the following command to permit the execution of the file.
    ‘sudo chmod u+x’
    Followed by the file name.
    • Once the file is executable, use the following command to run it and see the final results.
    ‘./Jose1.sh’
    
    Note: Remember to replace the name “Jose1.sh” with your file name.

    The program results after executing the bash shell scripting exercise challenge

    Finally, the lab end output should be as follows.

    Testing the file execution to ensure you meet the Bash shell scripting lab challenge requirements

    If you open and execute the file again, the list grows with 25 more files.

    Therefore, this is according to the lab challenge requirements. It stated that every time the script is executed, it creates 25 more empty files.

    Lab Completion

    At the end of the instructions, you will see an AWS lab complete note. At this point, go back to the top of the instructions page. To finish the lab session successfully, click the ‘End Lab’ button.

    After clicking the button mentioned above, the message menu below pops up. Click the “Yes” button in blue color.

    Next, click the “x” button on the top right corner to end the lab.

    Finally, the lab timer stops, and the provisioned resources are terminated.

    Author Recommendation

    You can modify the script to arrange the files in ascending order every time the script is executed. Feel free to use this guide to inspire your solution.

    Summary

    In conclusion, as a participant in the program, I witnessed its impact firsthand. From the fundamentals of AWS services to hands-on labs and real-world scenarios, AWS re/Start gave me a solid foundation to build upon.

  • Install AWS CLI on Windows OS Computer: How to Download and Install the AWS CLI Version 2

    Install AWS CLI on Windows OS Computer: How to Download and Install the AWS CLI Version 2

    After creating your AWS account, you can access it to provision resources or manage cloud services in the different ways AWS provides. First, you can access it through the AWS Management Console, which is the user’s graphical interface to access AWS Cloud Services. Secondly, you can access it through the AWS SDKs (Software Development Kits). These developer tools allow you to develop, build, deploy, or manage your applications in your AWS account. Thirdly, an AWS account can be accessed through a Command-Line Interface – AWS CLI.

    Similarly, this is the non-graphical user interface where interaction with the system is through text commands. Thus, the commands are written on a terminal interface, facilitating communication with your cloud resources and services. As a result, AWS has created a readily available Command Line Interface (AWS CLI) for Windows users.

    Introduction

    In the realm of cloud computing, efficiency and automation are key. Amazon Web Services (AWS) Command Line Interface (CLI) offers a streamlined way to locally interact with your AWS resources and(or) services directly from the command line. This empowers users like you and me to manage their cloud infrastructure easily.

    Whether you are a seasoned developer or just dipping your toes into the world of cloud computing, mastering the AWS CLI opens up a world of possibilities for accessing, building, and deploying resources on your AWS Cloud Services account.

    In this guide, I will help you unlock the power of cloud management. Following this tutorial, we will download and install AWS CLI on your Windows computer. Therefore, it is a set of simple steps curated to meet your installation needs.

    Before diving into the installation process, let’s briefly explore why you might choose to use the AWS CLI. In this tutorial, I’ve summarized four main reasons and benefits for using the AWS CLI.

    4 Top Benefits or Reasons Why You Must Use AWS CLI?

    1. Efficiency: Performing tasks via the command line can often be faster and more efficient than using a graphical interface.
    2. Automation: The AWS CLI allows you to reduce or eliminate repetition by automating daily tasks. Therefore, it saves you time and worries about making human errors.
    3. Flexibility: The AWS CLI tool gives you access to all AWS services and features, giving you unparalleled flexibility in managing your cloud infrastructure.
    4. Scalability: The AWS CLI scales to meet your needs, whether managing a small-scale deployment or a sprawling enterprise infrastructure.

    Now that we’ve highlighted the benefits, let’s begin the installation process.

    Downloading and Installing AWS CLI on Windows

    There are three simple steps to download, install, and verify the version of the AWS CLI installed. Follow them, and you will be done in a few minutes.

    Installing AWS CLI
    Simple steps to download and install the AWS CLI on a Windows 10 Machine.

    Step 1: Download the AWS CLI Installer.

    There are two ways to download the CLI installer for Windows. First, to save you time, I searched for the best and most reliable source and provided you with direct access to the installer. Therefore, you can confidently click the link below to download the installer because it is verified. You will be taken to the official AWS CLI documentation page: https://aws.amazon.com/cli/. The Windows installer is the first one on the list on the right side. You need to install the 64-bit version; therefore, click the “64-bit” link in blue.

    AWS CLI Download page.
    Click the 64-bit Windows installer link in blue color to download the AWS CLI.

    Saving the AWS CLI Installer Locally on Windows

    After clicking the 64-bit link, you will be prompted to save as the file on your computer. You will be prompted to save it in the downloads folder by default. Keep the default file name and click save.

    Save the Installer File in the Downloads Folder.
    Save the Installer File in the Downloads Folder.

    Immediately after the downloading process is complete, a notification will appear on the Google Chrome downloads icon.

    The downloading process is complete.
    You will be notified when the downloading process is complete.

    However, if it does not pop up or the notification window disappears before you see it, navigate to the downloads folder.

    Open the downloads folder and yo

    How to Change the Download Storage Location Folder.

    If you wish to change the storage location on your Windows computer, you can use the  “Save As” dialogue panel. To do this, click one of the available locations on the left side menu. For example, I selected Desktop to change from Downloads to Desktop.

    Changing the download storage location in your computer
    On the left side of the navigation menu, click to choose any of the storage locations to keep your downloaded file.

    Additionally, if you want to access more storage locations on your hard drive, click on the “This PC” menu. Next, scroll past the system folders to see the primary storage locations on your Windows computer hard drive. For example, the screenshot below shows three storage locations on my hard drive.

    Different hard drive storage locations.
    Click the “This PC” menu to access more storage locations on your hard disk drive.

    Pro Tips

    Double-click on any available storage to open it and store your file. If your hard drive has not been partitioned, you will only see one storage location when you open it.

    Therefore, you do not have to worry about it. Nonetheless, you can choose among the system folders such as 3D Objects, Desktop, Documents, Downloads, Music, Pictures, and Videos.

    Before we embark on step 2 of the downloading processing, let us look at an alternative way to download the AWS CLI installer.

    Alternative Downloading Method: How to Download AWS CLI Directly on your browser, such as Mozilla and Opera Mini

    If you are not interested in opening the provided link or it does not work on your current device, there is another way to do it. The second method is to use your favorite browser on your Windows machine to search for it online and follow the installation procedures. For example, my favorite browser is Google Chrome. I got this first search result by typing “AWS CLI for Window” in the search bar and pressing the enter button on my keyboard.

    Google Chrome browser search settings.
    Open your favorite browser, search AWS CLI for Windows, and press enter button on your keyboard.

    On the same note, you will receive similar results if you perform the exact search in your browser. Then, you can download it from one of the sources and install the AWS CLI. For example, my search results from the Mozilla Firefox browser were as follows.

    Mozilla Firefox Search Results
    Search results on the Mozilla Firefox browser.

    Similarly, an internet search using the OperaMini browser yielded the same search results. See the screenshot below as captured in realtime.

    Opera Mini browser search results.
    Similar internet search results that were obtained using the Opera Mini browser.

    Upon opening the first search result on any browser, you will land on this AWS Documentation page, as shown in the screenshot below. Every procedure described in it is correct. However, reading and choosing the correct download button or link will take time.

    AWS Documentation page for AWS CLI.
    Opening the first link on the search results leads to the official AWS CLI Documentation page.

    As you can see from above, the results are not specific, so you have to choose, unlike in method one, where I direct you to the exact installer version and download link.

    Pro Tip Recommendation

    Follow the first method. It directly opens the Official AWS downloads page, ensuring a reliable and secure file download. I tested it before writing this guide.

    Step 2: Run the Installer

    Navigate to the local storage location in your computer where you saved the installer. Next, double-click to run it. Then, follow the on-screen instructions to complete the installation process. For this tutorial, I opened the installer from the downloads storage location by clicking on it.

    Double click the installer to run it.
    Double clicking the installer opens the version 2 setup wizard.

    Then, as highlighted above, I clicked the “Next” button on the setup installation wizard. Next, I accepted the end-user agreement license for the wizard to proceed.

    Accept the end user agreement license.
    Select the checkbox below the license agreement to accept the end-user terms in the agreement.

    Select the box before the agreement statement and click next. The wizard will open the setup installation panel within a moment. Click Install at the bottom of the installation panel.

    Click the "Install" button to start the installation process.
    Click the install button to continue with the installation process.

    Next, when prompted by Microsoft Windows user account control to allow changes, click Yes to proceed.

    Click yes when prompted by the Microsoft Account Management wizard.
    Click “Yes” to allow the applications to make changes on your Windows computer.

    After that, the installation wizard will ask you to choose the default installation location or a custom installation. Leave the default and click next. By default, the installer will install it in the “C:\Program Files\Amazon\AWSCLI” directory.

    Default installation path or folder.
    Leave the installation folder and path as default.

    Then click next to install and wait for the installation process to complete.

    Installation in progress. Wait until the setup successfully finishes installatation.
    Installation in progress. Wait until the setup successfully finishes installing.

    The process takes a short while. When the setup is done, the following panel will appear, asking you to finish the installation.

    Wizard installation completed successfully.
    Click the “Finish” button to end the installation process of the Command Line Interface.

    Step 3: Verify the Installation

    Next, use the Windows command prompt terminal to verify that the Command Line Interface has been installed correctly. To open the command prompt (cmd), go to the Windows search bar on your taskbar and type cmd. From the popup menu, click open.

    Open the Windows 10 Commandline Interface (CMD) to verify installation.
    Open the Windows CMD to verify if the CLI version 2 has been installed successfully.

    Once the cmd opens, type the command aws –version and enter.

    Type in the CMD the verification command.

    If the installation was successful, you should see the version of the CLI displayed in the command prompt interface as follows.

    AWS CLI version 2 has been installed successfully on the Windows 10 machine.
    Now, you have verified that CLI was installed successfully on your Windows 10 computer or PC.

    Conclusion

    In conclusion, mastering the AWS CLI is a valuable skill for anyone working with AWS cloud services. By following the steps outlined in this guide, you can quickly download and install the AWS Command Line Interface on your Windows machine, enabling you to effectively manage your cloud services and resources using the command line.

    Whether you’re deploying new EC2 instances, managing S3 buckets, or automating complex workflows, the AWS CLI puts the power of AWS at your fingertips. Start exploring the possibilities today and unlock the full potential of cloud management with AWS CLI.