User data not executing node script when droplet is created over the api

Posted March 29, 2019 2.2k views
APIUbuntu 18.04

I am creating a droplet from a snapshot. The droplet contains a folder called youtube-uploader in the root directory. My cloud config looks like this:

  - touch test.txt
  - node /root/youtuber-uploader/index.js ID-1234
  - touch hello.txt

The droplet is created successfully but the node command is never executed. Both test.txt and hello.txt is created at /. If I ssh into the droplet and run the node command, everything works as expected.

I am making the call to the DO api through a node script and the axios package. The request looks like the following

axios('', {
    method: 'POST', 
    headers: {
       Authorization: 'xxxxxx'
    'Content-Type': 'application/json',
    data: {
      "name": 'testing'
      "region": "nyc3",
      "size": "s-6vcpu-16gb",
      "image": "45281496",
      "ssh_keys": [
      "backups": false,
      "ipv6": false,
      "user_data": `#cloud-config
  - touch test.txt
  - node /root/youtuber-uploader/index.js ${}
  - touch hello.txt`,
      "private_networking": null,
      "volumes": null,
      "tags": [

Is there any obvious mistake here? It might be that the script is being called but the id is not being passed so the script is not doing the work its supposed to. Is there anyway I can check for this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


Most likely the script is running, but not doing what you expect it to. You may be able to find helpful information in one of these log files:



  • The cloud-init-output.log file says Error: Cannot find module ’/root/youtube-uploader/index.js’.

    What could be the reason for this? The file certainly exists.