is now a part of Cisco. Learn More

About Cisco

Custom AMI - Shutdown Script

Shutdown Script

A user defined script which cmpute will execute before instances are terminated.

Below are the steps to follow before providing shutdown script for execution in a Custom AMI job:

  • Custom AMI job in cmpute should have an ‘Instance Profile’ associated with it. This instance profile should have access to s3 bucket in your AWS account.

  • Create a file named ‘config’ which should contain json structure having cmpute domain, cmpute access key and cmpute secret key.

For example:

         "tenant_url" : "https://<customer-domain>",
          "api_key" : "api key", 
          "secret_key" : "secret key"
  • Upload the ‘config’ file to the s3 bucket in your AWS account

  • While creating the custom AMI job in your cmpute platform, in the Launch script text box, include the following lines as the starting lines:

For Linux

        aws s3 cp s3://bucket/key/config {path-to-config} --region {region}
        aws s3 cp s3://shutdownscript/linux/shutdownscript {path-to-store-it} --region us-east-1
        chmod +x {path-to-shutdownScript} 
        {path-to-shutdownScript} {path-to-config} &

For Windows

        aws s3 cp s3://bucket/key/config {path-to-config} --region {region}
        aws s3 cp s3://shutdownscript/windows/shutdownscript.exe {path-to-store-it} --region us-east-1
        {path-to-shutdownScript} {path-to-config}