Resources
    Create a Cloud Function u ...
    26 August 22

    Create a Cloud Function using GCP Console

    Posted byINE
    facebooktwitterlinkedin
    news-featured

    In our lab walkthrough series, we go through selected lab exercises on our INE Platform. Subscribe or sign up for a 7-day, risk-free trial with INE and access this lab and a robust library covering the latest in Cyber Security, Networking, Cloud, and Data Science!

    Purpose: Google Cloud Functions is a serverless execution environment for building and connecting cloud services. With Cloud Functions you write simple, single-purpose functions that are attached to events emitted from your cloud infrastructure and services. In this article, we will learn how to create a Cloud Function using GCP Console.

    Technical difficulty:

    |   Novice   |   Beginner   |   Competent   |   Proficient   |   Expert

    Lab Scenario

    We have set up the below scenario in our INE labs for our students to practice. The screenshots have been taken from our online lab environment.

    Lab Link: Create a Cloud Function using GCP Console

    Objective

    In this lab, you will create a Cloud Function using the GCP console and invoke it.

    Solution

    Step 1: Choose the Start lab button and then choose Open lab. On the next page, agree to the terms and conditions and select Continue.

    You will be presented with access credentials, as shown in the following example. Open the GCP Portal Login link in a new private window or Incognito window.

    ccfugc3.png

    The URL will take you to the GCP login page. Use the provided credentials to log in.

    Step 2: Next, click on Accept on the subsequent page, check the Terms of Service checkbox and click on AGREE AND CONTINUE. (Make sure your country is correct)

    ccfugc4.png

    Now, we got access to the GCP account, let’s see how to create the Cloud Function!

    Step 1: On the next screen, you will be presented with the GCP home page. Now, using the search bar on the top, search for cloud functions and click on the Cloud Functions under Products & Pages.

    ccfugc5.png

    Step 2: You will be redirected to the Cloud Functions page. Now, click on CREATE FUNCTION and click ENABLE in the subsequent popup.

    ccfugc6.png

    Step 3: In the Create function page, under the Basics section, select the following options (see the screenshot for reference):

    Environment : 1st gen

    Function name : "helloWorld"

    Region : us-central1

    ccfugc7.png

    Step 4: Under Trigger section, select the following options (see the screenshot for reference):

    Trigger type : HTTP

    Authentication : Allow unauthenticated invocations

    ccfugc8.png

    Leave the rest as default and click Save, click Next to proceed to the Code section.

    Step 5: In the Code section, select the following options (see the screenshot for reference):

    Runtime : Python 3.9

    Source code : inline Editor

    Entry point : "hello_world"

    ccfugc9.png


    Step 6: Now, in the code editor, enter the code as shown in the screenshot and click Deploy.

    ccfugc10.png


    Step 7: You will be taken back to the Cloud Functions page, and wait for your function to be deployed. You can notice a Green Tick to the left of your function when deployed.

    ccfugc11.png

    We Successfully built and deployed the Cloud Function.

    Now, let’s invoke the Cloud Function.

    Step 1: To invoke your function, first, click on the name of your function.

    Under the TRIGGER tab, click on Target URL.

    ccfugc12.png

    Step 2: You can see that the link invokes your function and displays "Hello World!" in a new tab.

    ccfugc13.png

    Let’s see how to delete the Cloud Function.

    Step 1: To delete the function, click on the Delete option, and in the subsequent prompt, click DELETE.

    ccfugc14.png

    wait for the function to be deleted. Upon deletion, you will be taken back to the Cloud Functions page. Make sure your function is deleted.

    Conclusion

    Congratulations! In this lab, you created and deleted an Invokable Cloud Function using the GCP console.

    Try the GCP console for yourself hands-on! Subscribe or sign up for a 7-day, risk-free trial with INE to access this lab and a robust library covering the latest in Cyber Security, Networking, Cloud, and Data Science!

    © 2024 INE. All Rights Reserved. All logos, trademarks and registered trademarks are the property of their respective owners.
    instagram Logofacebook Logotwitter Logolinkedin Logoyoutube Logo