Lab Review: Working with the Google Cloud Console and Cloud Shell
1. Lab Review: Working with the Google Cloud Console and Cloud Shell
In this lab, you created a Cloud Storage bucket using both the Google Cloud console and Cloud Shell within Google Cloud. The Google Cloud Console can do things Cloud Shell can't do and vice versa. For example, the Google Cloud console can keep track of the context of your configuration activities. It can use the Cloud API to determine from current system state what options are valid, and it can perform repetitive and more leveraged activities on your behalf. Cloud Shell, in contrast, offers detailed and precise control, and through its commands, a way to script and automate activities. However, don't think of the console and Cloud Shell as alternatives. Think of them as one extremely flexible and powerful interface. You can stick around for a lab walkthrough, but remember that Google Cloud's user interface can change, so your environment might look slightly different. Hi, so here we are in the GCP Console and the first thing we're going to do is create a bucket using the GCP Console. So to do that, I'm going to use the navigation menu which is the icon up here in the top left corner, and I'm currently scroll down to Storage which is here, and click on Browser. What we want to do is create a bucket, so I'm going to click the Create bucket. The first thing we need to do is define a name, and now this name needs to be a globally unique name. So you could for example use your Qwiklab's project ID here, so that's what I'll do, copy that and paste it in there. The instructions just say to create, you could also choose a change the default storage class is currently set to multi-regional. We'll talk more about that in a later module. You can control the access to the objects and there are even some advanced settings around encryption. So I'm just going to go ahead and click Create. You can see that this now has created a bucket and here we see the bucket ID or the name. So now we're going to access Cloud Shell. Then what we're going to do this we're going to click this button up here on the right corner, says Activate Cloud Shell, and then it will prompt you to start clutches, so we'll click that as well. You can see that's coming up here. You could actually expand this and open this in a new tab, or you could realigned this to get a little bit more real estate in here. So we created a bucket using the GCP Console, now we're going to repeat the same using Cloud Shell. So I'm going to go ahead and copy the command from the lab instructions and paste it in here. Another command has the bucket name here in brackets and we want to change that. So this again has to be a globally unique name. So what we could do is we could again grab the ID of our project and maybe just add something to it. We could just add -shell to say that this is the one that we created from Cloud Shell. So the command is gsutil, these are the commands for Cloud Storage and mb is the make bucket command. You'll see that it has created that here, and we can see if we navigate in the GCP Console back to buckets, that we now have two buckets in here. So we're able to create both of those. So there are other Cloud Shell features that we can explore here. So while we're in Cloud Shell, we can click these three dots over here and get some more options. One of which is we can upload a file, and if I click that, I'm just present it with my browser, and I could for example, select this text file and click Open. We see that it's being uploaded and now that has finished, and then I can use the ls command to list that file. So here's that file. There's also a read me already in there. Then we could copy that now, that file to the bucket that we have. So there's a command for that also in the lab instructions. So again, we're working with Cloud Storage. So gsutil is going to be the command and CP to copy. We're going to give the name of the file, so MyFile.txt, and then we want to get to that Cloud Storage bucket. So we could choose either of the two buckets we've created. Why don't we choose the one we create a from Cloud Shell, paste it in there, and then it's telling us that it's copying over the files. If we now go into that, we can see that now that file is in there. The file doesn't contain anything, so that's why it is that size. Then we could also go ahead and close Cloud Shell, and do some other activities. Task 5 of the lab goes into creating a persistent state in Cloud Shell. So you could open Cloud Shell and we could list for example, all the variable regions with the G loud command that's listed in there, G Cloud compute regions list, and from these regions we can now select a region and store that in an environment variable. So let's take the command from the lab instructions and for class region equals, and let's say for example I pick the US Central 1 region, could paste that in there, store it, and then I could verify that with the echo command, just running that and it's not telling me that that is stored in there. The other thing we could do is we could expand this a little bit, we could also create a folder in here with the MK direct command, and now we could create a configuration file, and then we can append the environment variable that we just created to to that file. Then we could add another one for example, we could also store our project ID. So I can put that in there, grab my project ID, copy that, and store that in the environment variable, and then I run the command from the lab instructions to also append the value of the project ID to my environment variable and the configuration file. Then I can just verify all of that and make sure that that's been stored. So this gives us a method to create environment variables and easily recreate them as Cloud Shell is cycled. However, you will still need to remember to issue this source command each time Cloud Shell is opened. So let's modify the.profilefile so that the source command is issued automatically anytime a terminal Cloud Shell is opened. So we're going to close and reopen Cloud Shell. So let me do that, close it and then reopen it, and then I'm going to paste the echo command again. We see that it's not outputting anything, so that command is coming out down. So let's modify that.profilefile using nano, and at the end of that file, let's go all the way to the bottom. We'll go into paste in sourceinfraclassconfig, and then we're going to save that file to profile, and then exit. Then let's verify that we are able to get that environment variable, that is project ID. So that's currently not in there, that is because I haven't restarted it, propagates run when I restart, sorry for that. So let me close it, let me reopen it, and then let's verify. There we go. So now we can see that expected value and that's because we edit the d.profilefile. That's it. So we've leveraged in this lab, the GCP Console, we created a Storage bucket, we also created a Storage bucket using Cloud Shell, and then we looked into some features run Cloud Shell in terms of uploading files, than copying those files to the Storage bucket, and even at the end configuring the profile and setting some environment variables. That's the end of the lab.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.