This topic describes how to configure generated user data for an instance in the ECS console, and how to view and modify existing user data.
The user data function has the following limits:
- User data can be configured for instances in a VPC only.
- For phased-out instance types, only I/O-optimized instance types support user data. For other instance type families, all instance types support user data.
- User data must be Base64-encoded before it is configured for instances. Additionally, the original user data cannot exceed 16 KB.
- An instance must use a public image or a custom image that is created from a public
image. Furthermore, the following table describes the operating systems that are supported.
Platform Operating system Windows Windows Server 2008 R2 or later Linux
- SUSE Linux Enterprise
- Aliyun Linux
Configure user data for an instance
- Create a Linux instance by following the instructions in Create an instance by using the wizard.
Note During instance creation, enter user data in the user data box below Advanced Options (Instance RAM Roles and User Data cloud-init). If your user data is Base64-encoded, select the Enter Based64 Encoded Information check box.
- After the instance starts, connect to it by following the instructions in Overview of connecting to an ECS instance.
- Check the startup results against the configured user data. If exceptions occur, check
the log files. The following output is from a CentOS instance which is configured
with user data through an Upstart Job script:
As shown in the preceding output, a startup task file part-001.conf is created in the folder /etc/init of the instance.
You can also set user data by calling RunInstances through Alibaba Cloud CLI, OpenAPI Explorer, or Alibaba Cloud SDK. The relevant parameter is UserData.
View user data
You can view user data through the dedicated server 100.100.100.200. To do so, follow these steps:
- Connect to the instance. For more information, see Overview of connecting to an ECS instance.
- Run the following commands in the instance:
- For Linux, run curl http://100.100.100.200/latest/user-data.
- For Windows, run Invoke-RestMethod http://100.100.100.200/latest/user-data/.
You can also view user data by calling DescribeUserData through Alibaba Cloud CLI, OpenAPI Explorer, or Alibaba Cloud SDK.
Modify user data
- Find the target instance, and in the Actions column, choose .
- In the displayed dialog box, enter the relevant information and click OK.
You can also modify user data by calling ModifyInstanceAttribute through Alibaba Cloud CLI, OpenAPI Explorer, or Alibaba Cloud SDK.