# Getting Started With 
API Gateway and Cloud Functions

**Prerequisites:**

* Google Cloud Account
    
* Installing Google CLI
    
* Sample application to deploy to gcloud
    
* Postman to test
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692203866839/e2730eb6-d778-4651-ba03-27e1b4f24fd7.png align="center")

1. In the Google Cloud console, go to the Dashboard page and select or create a Google Cloud project.
    
    * Go to Dashboard Page [https://console.cloud.google.com/projectselector2/home/dashboard?\_ga=2.124589327.405847725.1691588802-1872602126.1691583025](https://console.cloud.google.com/projectselector2/home/dashboard?_ga=2.124589327.405847725.1691588802-1872602126.1691583025)
        
    * Select the Project as shown below and click on New Project
        

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692203986101/b5fd429c-5949-42c0-b9ea-3d5da9cc318c.png align="center")

* Name the Project as per Naming standards and click on create.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692204078012/8fc3ef1d-ebdf-4c76-9442-a08242809a54.png align="center")

1. Confirm billing is enabled for your project.
    
    https://cloud.google.com/billing/docs/how-to/modify-project
    

**Using Google Cloud CLI:**

1. Install Google CLI in Mac using bash.
    

* command to install CLI using bash
    

```plaintext
·       curl https://sdk.cloud.google.com | bash
```

* For other installation process for Mac or Windows.
    
    [https://cloud.google.com/sdk/docs/install-sdk](https://cloud.google.com/sdk/docs/install-sdk)
    

1. Login to gcloud in CLI
    

```plaintext
•	gcloud auth login 
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692206540387/a73cf514-71df-49c8-8e95-a4cd4b770708.png align="center")

1. To set Project Id
    

```plaintext
·       gcloud config set project projectId
```

* Get the project Id selecting the project and projectId can be found in the URL.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692206866087/09d4c004-ce7d-4e70-8b60-9c7d5818768d.png align="center")

1. To check if Service List enabled
    
    ```c
    ·       gcloud services list
    ```
    
    * Enabling required services
        
    
    API Gateway requires that you enable the following Google services:
    
    <table><tbody><tr><td colspan="1" rowspan="1"><p><strong>Name</strong></p></td><td colspan="1" rowspan="1"><p><strong>Title</strong></p></td></tr><tr><td colspan="1" rowspan="1"><p><a target="_blank" rel="noopener noreferrer nofollow" href="http://apigateway.googleapis.com" style="pointer-events: none">apigateway.googleapis.com</a></p></td><td colspan="1" rowspan="1"><p>API Gateway API</p></td></tr><tr><td colspan="1" rowspan="1"><p><a target="_blank" rel="noopener noreferrer nofollow" href="http://servicemanagement.googleapis.com" style="pointer-events: none">servicemanagement.googleapis.com</a></p></td><td colspan="1" rowspan="1"><p>Service Management API</p></td></tr><tr><td colspan="1" rowspan="1"><p><a target="_blank" rel="noopener noreferrer nofollow" href="http://servicecontrol.googleapis.com" style="pointer-events: none">servicecontrol.googleapis.com</a></p></td><td colspan="1" rowspan="1"><p>Service Control API</p></td></tr></tbody></table>
    
    * If you do not see the required services listed, enable them:
        
    
    ```c
    - gcloud services enable apigateway.googleapis.com
    - gcloud services enable servicemanagement.googleapis.com
    - gcloud services enable servicecontrol.googleapis.com
    ```
    
    1. Sample application to deploy to gcloud.
        

```c
cmd:
gcloud functions deploy java-http-function --gen2 --entry-point com.example.functions.Main --runtime=java11 –-{Region} --source={folderlocation} --trigger-http --allow-unauthenticated
```

```c
Example:
gcloud functions deploy java-http-function --gen2 --entry-point com.example.functions.Main --runtime=java11 --region=us-east1 --source=/Users/Downloads/gcp-cloud-functions --trigger-http --allow-unauthenticated
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692207462871/4549fcb3-d0db-4290-80fa-1ef74e4d679e.png align="center")

* On Completion of deployment Gcp URL will be generated to call
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692207479672/d5e3ff9a-72a5-4d01-a9cb-e3db2e01e338.png align="center")

1. Test the Endpoint URL with the Input as per your implementation.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692207619261/70fcb1d5-22a3-4a7c-b5c3-0fcee7a8f8b2.png align="center")

1. To trace Logs
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692207675119/226c33b7-2807-410b-b5ff-7cf9ca703dd7.png align="center")
