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.
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.