Triage and Remediation
Remediation
Using Console
Using Console
To remediate the issue of Cloud Functions not using the latest runtimes in GCP, follow these steps:
- Open the GCP console and navigate to the Cloud Functions page.
- Select the function that needs to be updated.
- Click on the “Edit” button to edit the function.
- In the “Runtime” field, select the latest version of the runtime that is available.
- Click on the “Save” button to save the changes.
Using CLI
Using CLI
To remediate the misconfiguration “Cloud Functions Should Use Latest Runtimes” for GCP using GCP CLI, follow the steps below:
- Open the Google Cloud SDK Shell or any terminal on your local machine.
-
Authenticate to your GCP account using the command:
-
Set the project where the Cloud Function is located using the command:
-
List all the Cloud Functions in the project using the command:
- Identify the Cloud Function that is not using the latest runtime.
-
Update the Cloud Function to use the latest runtime version using the command:
Replace [FUNCTION_NAME] with the name of the Cloud Function you want to update and [RUNTIME_VERSION] with the latest version of the runtime for your programming language. For example, if you are using Node.js, the latest version of the runtime is Node.js 14, so you would use
--runtime nodejs14
. -
Verify that the Cloud Function is using the latest runtime by checking the Cloud Function details using the command:
The output should show that the runtime label is set to “latest”.
Using Python
Using Python
To remediate the misconfiguration “Cloud Functions should use latest runtimes” in GCP using Python, you can follow the below steps:
- Open the Google Cloud Console and navigate to the Cloud Functions page.
- Select the function for which you want to update the runtime.
- Click on the “Edit” button to modify the function.
- In the “Runtime” section, select the latest version of the runtime that you want to use.
- Click on the “Deploy” button to update the function with the latest runtime.
- Open the command prompt or terminal on your local machine.
- Login to your GCP account using the command “gcloud auth login”.
- Set the project to the one where your function is deployed using the command “gcloud config set project [PROJECT_ID]”.
- Update the runtime of the function using the command “gcloud functions deploy [FUNCTION_NAME] —runtime [RUNTIME_VERSION]”.