I need to make this request from a Google Cloud Function:
POST https://compute.googleapis.com/compute/v1/projects/project-id/zones/zone/instanceGroupManagers/instance-group-name/resize?size=new-size
as per these docs: https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-managed-instances#api_2
I understand how to assign a JSON service-account key and do it with a googleapi
library. But in this case all I need the function to do is this single request. So, I'd like to do it simply with fetch()
. How do I write the authorization?
const url = `https://compute.googleapis.com/compute/v1/projects/${projectId}/zones/${zone}/instanceGroupManagers/${instanceGroupName}/resize?size=${size}`
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
const responseJson = response.json();