Create a project by using Simple Log Service SDK for Python

Updated at:

Call the create_project method to create a Simple Log Service project in a specific region.

Prerequisites

Method signature

def create_project(self, project_name, project_des, resource_group_id='', data_redundancy_type=None):

Request parameters

The create_project method supports the following parameters.

Parameter Type Required Description
project_name String Yes The name of the project. The name must be globally unique within an Alibaba Cloud region and cannot be modified after creation. For naming rules, see Project naming rules.
project_des String Yes The description of the project. The description can contain up to 64 characters and must not contain angle brackets (<>), apostrophes ('), backslashes (\), double quotes ("), or double backslashes (\\).
resource_group_id String No The ID of the resource group. If not specified, the default resource group is used. For more information, see Create a resource group.
data_redundancy_type String No The data redundancy type. By default, locally redundant storage (LRS) is used. Some regions offer both LRS and zone-redundant storage (ZRS). The redundancy type cannot be changed after the project is created. Valid values: LRS and ZRS. For more information, see Storage redundancy.

Project naming rules

The project name must meet the following requirements:

  • Must be globally unique within an Alibaba Cloud region.

  • Can contain only lowercase letters, digits, and hyphens (-).

  • Must start and end with a lowercase letter or digit.

  • Must be 3 to 63 characters in length.

Response parameters

The create_project method returns a CreateProjectResponse object. For details about the response parameters, see CreateProject.

Sample code

The following example creates a Simple Log Service project.

from aliyun.log import LogClient
import os

# Obtain the AccessKey ID and AccessKey secret from environment variables.
accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

# Specify the Simple Log Service endpoint.
# In this example, the endpoint for the Singapore region is used.
# Replace the value with the endpoint for your region.
endpoint = "ap-southeast-1.log.aliyuncs.com"

# Create a Simple Log Service client.
client = LogClient(endpoint, accessKeyId, accessKey)

# Specify the project name.
project_name = "slsproject-1"

# Specify the project description. Set project_des to an empty string
# if you do not want to add a description.
project_des = "this is a project created from ide."


def main():
    """Create a project. If no exception is thrown, the project is created."""
    try:
        res = client.create_project(project_name, project_des)
        res.log_print()
    except Exception as error:
        print(error)


if __name__ == '__main__':
    main()

Sample response

A successful call returns the following response:

CreateProjectResponse:
headers: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Mon, 16 Feb 2026 18:00:04 GMT', 'x-log-time': '1771264804', 'x-log-requestid': '69935B229875CE12BF68D4A6'}

Process finished with exit code 0

References