Unfortunately, such VMs aren't available for GCP and AWS.
GCP
Have a look at the documentation Machine types:
A machine type is a set of virtualized hardware resources available to
a virtual machine (VM) instance, including the system memory size,
virtual CPU (vCPU) count, and persistent disk limits. In Compute
Engine, machine types are grouped and curated by families for
different workloads. You can choose from general-purpose,
memory-optimized, and compute-optimized families.
You must choose a machine type when you create an instance. You can select from a number of predefined machine types in each machine type
family. If the predefined machine types do not meet your needs, you
can create your own custom machine types.
and at the Changing the Machine Type of a Stopped Instance:
You can change the machine type of a stopped instance if it is not part of a managed instance group.
So, as you can see, it's not possible to have dynamic CPU/RAM for GCP VMs.
As a possible workaround for GCP, you can try to file a feature request at Google Issue Tracker.
AWS
Have a look at the documentation Instance types:
When you launch an instance, the instance type that you specify
determines the hardware of the host computer used for your instance.
Each instance type offers different compute, memory, and storage
capabilities and are grouped in instance families based on these
capabilities. Select an instance type based on the requirements of the
application or software that you plan to run on your instance.
then at the Changing the instance type:
As your needs change, you might find that your instance is
over-utilized (the instance type is too small) or under-utilized (the
instance type is too large). If this is the case, you can change the
size of your instance.
and at the section Resizing an Amazon EBS–backed instance:
You must stop your Amazon EBS–backed instance before you can change
its instance type.
also at the section Migrating an instance store-backed instance:
When you want to move your application from one instance store-backed
instance to an instance store-backed instance with a different
instance type, you must migrate it by creating an image from your
instance, and then launching a new instance from this image with the
instance type that you need.
As you can see, it's quite the same story for AWS VMs.
You can try to request such feature by following this document.