I wanted to know if there is a way to apply rightsizing recommendation which is provided for VM using an API call instead of doing it through UI in GCP Compute Engine?
For ex: if there is a VM with config 16vCPUs and 40GB mem, and if the rightsizing recommendation on usage basis is to change the config to 12vCPUs and 20GB, Is there an API available which performs this action?
I know it can be done manually through the interface.
Thanks.
You can use the CLI to change the machine type for a Compute Engine instance.
Where MACHINE-TYPE can be a predefinded machine type or a custom machine type.
Predefined Machine Types
Custom Machine Types
The instance must be stopped. Ephemeral external IP addresses might change.
Best practices recommend creating a snapshot of the disks before changing the instance.
Changing a machine type documentation link