I am developing a project in Google Cloud using both their App Engine and Compute Engine. I have a virtual machine instance set up on Compute Engine, with the name "instance-1". On this instance is the python file (file.py):
name = '<REPLACE_WITH_YOUR_NAME>'
print(name)
Well, this isn't exactly the file.py, but the concept applies below. Additionally, I have an App Engine project written in NodeJS, which is connecting to this instance via Google's Compute Engine API. Here is what I have in regards to that:
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-east1-b');
const vm_name = 'instance-1';
const vm = zone.vm(vm_name);
const my_name = "David Weiss"
// TODO: insert the variable my_name into the python code file.py where it says '<REPLACE_WITH_YOUR_NAME>'
// In my head, it would look something like this: vm.getFile('file.py', 'write').replace('<REPLACE_WITH_YOUR_NAME>', my_name);
After getting the instance 'instance-1, I don't know how to modify (or even add/replace/delete) files on it using NodeJS and the Compute Engine API. Can this be done? If it's not possible to replace the text within file.py, I would be okay with deleting the entire file and just writing a brand new file with my_name already inserted in there.