1. Registry
  2. Packages
  3. Alibaba Cloud Provider
  4. API Docs
  5. cms
  6. getDatasets
Viewing docs for Alibaba Cloud v3.108.0
published on Thursday, Sep 17, 2026 by Pulumi
alicloud logo alicloud logo
Viewing docs for Alibaba Cloud v3.108.0
published on Thursday, Sep 17, 2026 by Pulumi

    This data source provides the Cms Datasets of the current Alibaba Cloud user.

    NOTE: Available since v1.292.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const defaultProject = new alicloud.log.Project("default", {projectName: name});
    const defaultWorkspace = new alicloud.cms.Workspace("default", {
        workspaceName: name,
        slsProject: defaultProject.projectName,
    });
    const defaultDataset = new alicloud.cms.Dataset("default", {
        workspace: defaultWorkspace.workspaceName,
        datasetName: name,
        description: "terraform-example",
        schema: JSON.stringify({
            type: "record",
            name: "example",
            fields: [{
                name: "metric",
                type: "string",
            }],
        }),
    });
    const _default = alicloud.cms.getDatasetsOutput({
        workspace: defaultWorkspace.workspaceName,
        ids: [defaultDataset.id],
    });
    export const cmsDatasetId1 = _default.apply(_default => _default.datasets?.[0]?.id);
    
    import pulumi
    import json
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default_project = alicloud.log.Project("default", project_name=name)
    default_workspace = alicloud.cms.Workspace("default",
        workspace_name=name,
        sls_project=default_project.project_name)
    default_dataset = alicloud.cms.Dataset("default",
        workspace=default_workspace.workspace_name,
        dataset_name=name,
        description="terraform-example",
        schema=json.dumps({
            "type": "record",
            "name": "example",
            "fields": [{
                "name": "metric",
                "type": "string",
            }],
        }))
    default = alicloud.cms.get_datasets_output(workspace=default_workspace.workspace_name,
        ids=[default_dataset.id])
    pulumi.export("cmsDatasetId1", default.datasets[0].id)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/cms"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/log"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultProject, err := log.NewProject(ctx, "default", &log.ProjectArgs{
    			ProjectName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		defaultWorkspace, err := cms.NewWorkspace(ctx, "default", &cms.WorkspaceArgs{
    			WorkspaceName: pulumi.String(name),
    			SlsProject:    defaultProject.ProjectName,
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"type": "record",
    			"name": "example",
    			"fields": []map[string]string{
    				{
    					"name": "metric",
    					"type": "string",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		defaultDataset, err := cms.NewDataset(ctx, "default", &cms.DatasetArgs{
    			Workspace:   defaultWorkspace.WorkspaceName,
    			DatasetName: pulumi.String(name),
    			Description: pulumi.String("terraform-example"),
    			Schema:      pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		_default := cms.GetDatasetsOutput(ctx, cms.GetDatasetsOutputArgs{
    			Workspace: defaultWorkspace.WorkspaceName,
    			Ids: pulumi.StringArray{
    				defaultDataset.ID().ToIDOutput().ToStringOutput(),
    			},
    		}, nil)
    		ctx.Export("cmsDatasetId1", _default.ApplyT(func(_default cms.GetDatasetsResult) (*string, error) {
    			return _default.Datasets[0].Id, nil
    		}).(pulumi.StringPtrOutput))
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var defaultProject = new AliCloud.Log.Project("default", new()
        {
            ProjectName = name,
        });
    
        var defaultWorkspace = new AliCloud.Cms.Workspace("default", new()
        {
            WorkspaceName = name,
            SlsProject = defaultProject.ProjectName,
        });
    
        var defaultDataset = new AliCloud.Cms.Dataset("default", new()
        {
            Workspace = defaultWorkspace.WorkspaceName,
            DatasetName = name,
            Description = "terraform-example",
            Schema = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["type"] = "record",
                ["name"] = "example",
                ["fields"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["name"] = "metric",
                        ["type"] = "string",
                    },
                },
            }),
        });
    
        var @default = AliCloud.Cms.GetDatasets.Invoke(new()
        {
            Workspace = defaultWorkspace.WorkspaceName,
            Ids = new[]
            {
                defaultDataset.Id,
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["cmsDatasetId1"] = @default.Apply(@default => @default.Apply(getDatasetsResult => getDatasetsResult.Datasets[0]?.Id)),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.log.Project;
    import com.pulumi.alicloud.log.ProjectArgs;
    import com.pulumi.alicloud.cms.Workspace;
    import com.pulumi.alicloud.cms.WorkspaceArgs;
    import com.pulumi.alicloud.cms.Dataset;
    import com.pulumi.alicloud.cms.DatasetArgs;
    import com.pulumi.alicloud.cms.CmsFunctions;
    import com.pulumi.alicloud.cms.inputs.GetDatasetsArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var config = ctx.config();
            final var name = config.get("name").orElse("terraform-example");
            var defaultProject = new Project("defaultProject", ProjectArgs.builder()
                .projectName(name)
                .build());
    
            var defaultWorkspace = new Workspace("defaultWorkspace", WorkspaceArgs.builder()
                .workspaceName(name)
                .slsProject(defaultProject.projectName())
                .build());
    
            var defaultDataset = new Dataset("defaultDataset", DatasetArgs.builder()
                .workspace(defaultWorkspace.workspaceName())
                .datasetName(name)
                .description("terraform-example")
                .schema(serializeJson(
                    jsonObject(
                        jsonProperty("type", "record"),
                        jsonProperty("name", "example"),
                        jsonProperty("fields", jsonArray(jsonObject(
                            jsonProperty("name", "metric"),
                            jsonProperty("type", "string")
                        )))
                    )))
                .build());
    
            final var default = CmsFunctions.getDatasets(GetDatasetsArgs.builder()
                .workspace(defaultWorkspace.workspaceName())
                .ids(defaultDataset.id())
                .build());
    
            ctx.export("cmsDatasetId1", default_.applyValue(_default_ -> _default_.datasets()[0].id()));
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultProject:
        type: alicloud:log:Project
        name: default
        properties:
          projectName: ${name}
      defaultWorkspace:
        type: alicloud:cms:Workspace
        name: default
        properties:
          workspaceName: ${name}
          slsProject: ${defaultProject.projectName}
      defaultDataset:
        type: alicloud:cms:Dataset
        name: default
        properties:
          workspace: ${defaultWorkspace.workspaceName}
          datasetName: ${name}
          description: terraform-example
          schema:
            fn::toJSON:
              type: record
              name: example
              fields:
                - name: metric
                  type: string
    variables:
      default:
        fn::invoke:
          function: alicloud:cms:getDatasets
          arguments:
            workspace: ${defaultWorkspace.workspaceName}
            ids:
              - ${defaultDataset.id}
    outputs:
      cmsDatasetId1: ${default.datasets[0].id}
    
    pulumi {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_cms_getdatasets" "default" {
      workspace = alicloud_cms_workspace.default.workspace_name
      ids       = [alicloud_cms_dataset.default.id]
    }
    
    resource "alicloud_log_project" "default" {
      project_name = var.name
    }
    resource "alicloud_cms_workspace" "default" {
      workspace_name = var.name
      sls_project    = alicloud_log_project.default.project_name
    }
    resource "alicloud_cms_dataset" "default" {
      workspace    = alicloud_cms_workspace.default.workspace_name
      dataset_name = var.name
      description  = "terraform-example"
      schema = jsonencode({
        "type" = "record"
        "name" = "example"
        "fields" = [{
          "name" = "metric"
          "type" = "string"
        }]
      })
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    output "cmsDatasetId1" {
      value = data.alicloud_cms_getdatasets.default.datasets[0].id
    }
    

    Using getDatasets

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getDatasets(args: GetDatasetsArgs, opts?: InvokeOptions): Promise<GetDatasetsResult>
    function getDatasetsOutput(args: GetDatasetsOutputArgs, opts?: InvokeOutputOptions): Output<GetDatasetsResult>
    def get_datasets(dataset_name_regex: Optional[str] = None,
                     ids: Optional[Sequence[str]] = None,
                     output_file: Optional[str] = None,
                     workspace: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetDatasetsResult
    def get_datasets_output(dataset_name_regex: pulumi.Input[Optional[str]] = None,
                     ids: pulumi.Input[Optional[Sequence[pulumi.Input[str]]]] = None,
                     output_file: pulumi.Input[Optional[str]] = None,
                     workspace: pulumi.Input[Optional[str]] = None,
                     opts: Optional[InvokeOutputOptions] = None) -> Output[GetDatasetsResult]
    func GetDatasets(ctx *Context, args *GetDatasetsArgs, opts ...InvokeOption) (*GetDatasetsResult, error)
    func GetDatasetsOutput(ctx *Context, args *GetDatasetsOutputArgs, opts ...InvokeOption) GetDatasetsResultOutput

    > Note: This function is named GetDatasets in the Go SDK.

    public static class GetDatasets 
    {
        public static Task<GetDatasetsResult> InvokeAsync(GetDatasetsArgs args, InvokeOptions? opts = null)
        public static Output<GetDatasetsResult> Invoke(GetDatasetsInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetDatasetsResult> Invoke(GetDatasetsInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetDatasetsResult> getDatasets(GetDatasetsArgs args, InvokeOptions options)
    public static Output<GetDatasetsResult> getDatasets(GetDatasetsArgs args, InvokeOptions options)
    public static Output<GetDatasetsResult> getDatasets(GetDatasetsArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: alicloud:cms/getDatasets:getDatasets
      arguments:
        # arguments dictionary
    data "alicloud_cms_get_datasets" "name" {
        # arguments
    }

    The following arguments are supported:

    Workspace string
    The name of the workspace to which the datasets belong.
    DatasetNameRegex string
    A regex string to filter results by Dataset name.
    Ids List<string>
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Workspace string
    The name of the workspace to which the datasets belong.
    DatasetNameRegex string
    A regex string to filter results by Dataset name.
    Ids []string
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    workspace string
    The name of the workspace to which the datasets belong.
    dataset_name_regex string
    A regex string to filter results by Dataset name.
    ids list(string)
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    output_file string
    File name where to save data source results (after running pulumi preview).
    workspace String
    The name of the workspace to which the datasets belong.
    datasetNameRegex String
    A regex string to filter results by Dataset name.
    ids List<String>
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    workspace string
    The name of the workspace to which the datasets belong.
    datasetNameRegex string
    A regex string to filter results by Dataset name.
    ids string[]
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    workspace str
    The name of the workspace to which the datasets belong.
    dataset_name_regex str
    A regex string to filter results by Dataset name.
    ids Sequence[str]
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    output_file str
    File name where to save data source results (after running pulumi preview).
    workspace String
    The name of the workspace to which the datasets belong.
    datasetNameRegex String
    A regex string to filter results by Dataset name.
    ids List<String>
    A list of Dataset IDs. Its element value is formatted as <workspace>:<dataset_name>.
    outputFile String
    File name where to save data source results (after running pulumi preview).

    getDatasets Result

    The following output properties are available:

    Datasets List<Pulumi.AliCloud.Cms.Outputs.GetDatasetsDataset>
    A list of Cms Datasets. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Workspace string
    The name of the workspace to which the dataset belongs.
    DatasetNameRegex string
    OutputFile string
    Datasets []GetDatasetsDataset
    A list of Cms Datasets. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Workspace string
    The name of the workspace to which the dataset belongs.
    DatasetNameRegex string
    OutputFile string
    datasets list(object)
    A list of Cms Datasets. Each element contains the following attributes:
    id string
    The provider-assigned unique ID for this managed resource.
    ids list(string)
    workspace string
    The name of the workspace to which the dataset belongs.
    dataset_name_regex string
    output_file string
    datasets List<GetDatasetsDataset>
    A list of Cms Datasets. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    workspace String
    The name of the workspace to which the dataset belongs.
    datasetNameRegex String
    outputFile String
    datasets GetDatasetsDataset[]
    A list of Cms Datasets. Each element contains the following attributes:
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    workspace string
    The name of the workspace to which the dataset belongs.
    datasetNameRegex string
    outputFile string
    datasets Sequence[GetDatasetsDataset]
    A list of Cms Datasets. Each element contains the following attributes:
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    workspace str
    The name of the workspace to which the dataset belongs.
    dataset_name_regex str
    output_file str
    datasets List<Property Map>
    A list of Cms Datasets. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    workspace String
    The name of the workspace to which the dataset belongs.
    datasetNameRegex String
    outputFile String

    Supporting Types

    GetDatasetsDataset

    CreateTime string
    The creation time of the resource.
    DatasetName string
    The name of the resource.
    Description string
    The description of the dataset.
    Id string
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    RegionId string
    The region ID of the resource.
    UpdateTime string
    The last modified time of the resource.
    Workspace string
    The name of the workspace to which the datasets belong.
    CreateTime string
    The creation time of the resource.
    DatasetName string
    The name of the resource.
    Description string
    The description of the dataset.
    Id string
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    RegionId string
    The region ID of the resource.
    UpdateTime string
    The last modified time of the resource.
    Workspace string
    The name of the workspace to which the datasets belong.
    create_time string
    The creation time of the resource.
    dataset_name string
    The name of the resource.
    description string
    The description of the dataset.
    id string
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    region_id string
    The region ID of the resource.
    update_time string
    The last modified time of the resource.
    workspace string
    The name of the workspace to which the datasets belong.
    createTime String
    The creation time of the resource.
    datasetName String
    The name of the resource.
    description String
    The description of the dataset.
    id String
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    regionId String
    The region ID of the resource.
    updateTime String
    The last modified time of the resource.
    workspace String
    The name of the workspace to which the datasets belong.
    createTime string
    The creation time of the resource.
    datasetName string
    The name of the resource.
    description string
    The description of the dataset.
    id string
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    regionId string
    The region ID of the resource.
    updateTime string
    The last modified time of the resource.
    workspace string
    The name of the workspace to which the datasets belong.
    create_time str
    The creation time of the resource.
    dataset_name str
    The name of the resource.
    description str
    The description of the dataset.
    id str
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    region_id str
    The region ID of the resource.
    update_time str
    The last modified time of the resource.
    workspace str
    The name of the workspace to which the datasets belong.
    createTime String
    The creation time of the resource.
    datasetName String
    The name of the resource.
    description String
    The description of the dataset.
    id String
    The ID of the resource. It is formatted as <workspace>:<dataset_name>.
    regionId String
    The region ID of the resource.
    updateTime String
    The last modified time of the resource.
    workspace String
    The name of the workspace to which the datasets belong.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo alicloud logo
    Viewing docs for Alibaba Cloud v3.108.0
    published on Thursday, Sep 17, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial