All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term


Use custom data

Last updated:2021-08-04 11:26:31

When creating a KEC instance, you can specify an executable custom data script and configure the instance to, for example, download, upgrade, and install software, modify system configuration, and initialize the service environment.

Custom data supports many types of common scripts, such as shell scripts.


  • Currently, custom data is supported only on Linux operating systems. It is not supported on Windows operating systems.
  • Image support

    • Standard images: The function can be normally used on KEC instances created in data centers in CN North 1(Beijing), CN East 1(Shanghai), and CN South 1(Guangzhou) after November 1, 2019. It is not supported for data centers in Hong Kong, Singapore, and Russia at present.

    • Custom images and shared images: The function can be normally used when you use custom images or shared images that are based on KEC instances created after October 30, 2019.

      To use custom data for custom images or shared images that do not meet the above conditions, refer to Install the cloud-init service.

    • Image marketplace: Images purchased from the marketplace do not support custom data. To use the function, refer to Install the cloud-init service.


  • The custom data script is executed only when the KEC instance is started for the first time or the system is reinstalled, and is not executed when the KEC instance is restarted.
  • When the KEC instance is started for the first time, executing the custom data script will increase the startup time of the instance. It is recommended that you wait for all startup items to be loaded before verifying the execution of the script.
  • When preparing a custom data script, you must use #!/bin/bash as the first line and the script file cannot exceed 16 KB.


The script used in this topic is an example that writes the instance startup time and specified text to the output.txt file.

  1. Prepare a shell script.

    echo "Hello World. The time is now $(date -R)!" | tee /root/output.txt
    service httpd start
    chkconfig httpd on
  2. Log in to the KEC console. When you create an instance, click Advanced Options in the System Configuration step.

    For more information about creating an instance, see Create an instance.

  3. In (Optional) Custom Data, enter the prepared shell script.


    The parameter also supports Base64 encoding format. If the entered script is Base64 encoded, you must also select The input content has been encoded in Base64..

  4. After the instance is created, log in to the instance and verify the execution of the script.


On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen