Google startup script on custom image not working - google-cloud-platform

I have launched a VM in GCP using a custom image from GCP console.
I have added a start-up script while launching the VM.
When I login into the VM, I have observed that my start-up script is not executed.
I have gone through the log file and observed the " No start-up script found" message in /var/log/syslog.
Note : Start-up scripts execute successfully for VM's launched using GCP default images.
Can any one help me on how to execute start-up scripts for VM's launched using custom images.

Related

Can we run the jar in the GCP VM from the cloud function

Can we run the jar in the GCP VM from the cloud function-
We thaught of deploying the jar in cloud function directly and running from there but we encountered the execution time out issues, so Is there any way that we can just to trigger the jar file in GCP VM from cloud function
Thanks in advance
If the only purpose of the VM is to run this process I would:
Cloud Scheduler calls a Cloud Function.
The Cloud Function starts a VM with a startup script that runs the jar process, and shuts down.
If you need to pass arguments to the script, you can do it using instance metadata when you create the instance (or while it is already running).
You can also have a look at this article (which is not supported by google). There you will find how you can start and stop instances using cloud functions.

How can solve a scheduling problem a .ipnyb notebook in Sagemaker using AWS lambda and Lifecycle Configuration?

I want to schedule my .ipynb file with Amazon Lambda. I am following the steps of this publications https://towardsdatascience.com/automating-aws-sagemaker-notebooks-2dec62bc2c84. For notebook instance is working very well starting and stoping, but my .ipynb file is not executing, i wrote as the same above mentioned publication in lifecycle configuration.
Just i change these lines with my notebook instance source
"NOTEBOOK_FILE="/home/ec2-user/SageMaker/Test Notebook.ipynb"
/home/ec2-user/anaconda3/bin/activate "$ENVIRONMENT"
"source /home/ec2-user/anaconda3/bin/deactivate".
Cloudwatch is working very well for notebook instance, but .ipynb file is not executed.
Can someone help me about my problem!
Check out the this aws-sample of how to run a notebook in aws-sagemaker.
This document shows how to install and run the sagemaker-run-notebooks library that lets you run and schedule Jupyter notebook executions as SageMaker Processing Jobs.
This library provides three interfaces to the notebook execution functionality:
A command line interface (CLI)
A Python library
A JupyterLab extension that can be enabled for JupyterLab running locally, in SageMaker Studio, or on a SageMaker notebook instance
https://github.com/aws-samples/sagemaker-run-notebook
Also, check out this example of Scheduling Jupyter notebooks on SageMaker. you can write code in a Jupyter notebook and run it on an Amazon SageMaker ephemeral instance with the click of a button, either immediately or on a schedule. With the tools provided here, you can do this from anywhere: at a shell prompt, in JupyterLab on Amazon SageMaker, in another JupyterLab environment you have, or automated in a program you’ve written.
https://aws.amazon.com/blogs/machine-learning/scheduling-jupyter-notebooks-on-sagemaker-ephemeral-instances/

How to run .exe file on startup on gcp windows instance

I am having a VM, windows instance (GCE) on google cloud platform. I want to run a program(.exe) every time at the start of the instance.
I am able to run the file by putting it in the startup folder. but I want to run it using startup script as suggested by google here: running startup scripts on a google compute engine
To run .exe on GCP when Windows VM instance start/restart.
Click edit on VM instance
Expand Management, security, disks, networking, sole tenancy section
In the Metadata section, provide windows-startup-script-cmd as the metadata key.
In the Value box, provide /path/to/exe-file

Run a batch file on EC2 from a (python) lambda

I can see a generic way of starting an EC2 from lambda in Start and Stop Instances at Scheduled Intervals Using Lambda and CloudWatch.
Suppose I use that method to start an EC2, and suppose the AMI is a windows server 2019 customised to have a .bat file on the desktop, and also suppose I'm using a python lambda.
How can I execute this batch file from the lambda? (i.e. just as though someone had RDP'd into the instance and double-clicked on it)
Note: To be very clear, basically I want to start the EC2 using the method given in the AWS docs (above), and right after the instance has started, to run the batch file that will be sitting on the instance's desktop
I think you have a few concepts mixed together.
AWS Lambda functions run on the Lambda service, without having to use Amazon EC2 instances. This is what makes them "serverless".
If you have a batch file on an Amazon EC2 instance, you would presumably want to run that batch file on the EC2 instance itself, without involving Lambda (since you have got a server).
If you wish to run a script on an EC2 instance when it launches for the first time, you can provide a PowerShell or Command-Line script via the User Data field. Software on the AMI will automatically execute this script the first time that the instance starts.
This script could do all the work itself, or it could simply call another script that is stored on the disk. Some people use the script to download another script from a repository (eg Amazon S3 or GitHub) and then execute the downloaded script.
For more information, see: Running Commands on Your Windows Instance at Launch - Amazon Elastic Compute Cloud
If the Amazon EC2 instance is already running and you wish to trigger a script to execute, you can use the AWS Systems Manager Run Command. This works by having an agent on the instance which can be remotely triggered, thereby running scripts without having to login to the instance.

accessing a new vm's terminal without using the console in UI

I'm new to vmware and i'm trying to do some automation when creating a vm from an OVA file. Essentially, I have an OVA that I need to get into the console and run a script so I can get to it via the internet...the script is this (runs a netplan config and some iptable commands), I just don't know how to execute or run the commands manually without having to get into the UI via the console.
I'm just trying to figure out how I can run this without having to access the console via the vmware esxi UI.
I'm using packet.com's environment to provision a server with vmware esxi on it via terraform, and then use ansible to deploy a few ova's on it.
The problem then is though that I can't access the newly deployed vm's unless I go into the console of the vm via the UI. I'm trying to see how I can do that either via an api or some other fashion so I can do some further automation after the VM's come up.
Assuming the VM has VMware Tools running, that would give you access to run a process/command/script in the Guest OS using the GuestProcessManager object in the vSphere Web Services API. More specifically, using the StartProgramInGuest method: http://pubs.vmware.com/vsphere-6-5/topic/com.vmware.wssdk.apiref.doc/vim.vm.guest.ProcessManager.html#startProgram