1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. arms
  5. getEnvironments
Alibaba Cloud v3.85.0 published on Tuesday, Sep 9, 2025 by Pulumi

alicloud.arms.getEnvironments

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.85.0 published on Tuesday, Sep 9, 2025 by Pulumi

    This data source provides the ARMS Environments of the current Alibaba Cloud user.

    NOTE: Available since v1.258.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    import * as random from "@pulumi/random";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.resourcemanager.getResourceGroups({
        status: "OK",
    });
    const defaultGetNetworks = alicloud.vpc.getNetworks({
        nameRegex: "^default-NODELETING$",
    });
    const defaultInteger = new random.index.Integer("default", {
        min: 10000,
        max: 99999,
    });
    const defaultEnvironment = new alicloud.arms.Environment("default", {
        bindResourceId: defaultGetNetworks.then(defaultGetNetworks => defaultGetNetworks.ids?.[0]),
        environmentSubType: "ECS",
        environmentType: "ECS",
        environmentName: `${name}-${defaultInteger.result}`,
        resourceGroupId: _default.then(_default => _default.ids?.[1]),
        tags: {
            Created: "TF",
            For: "Environment",
        },
    });
    const ids = alicloud.arms.getEnvironmentsOutput({
        ids: [defaultEnvironment.id],
    });
    export const armsEnvironmentsId0 = ids.apply(ids => ids.environments?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    import pulumi_random as random
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.resourcemanager.get_resource_groups(status="OK")
    default_get_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
    default_integer = random.index.Integer("default",
        min=10000,
        max=99999)
    default_environment = alicloud.arms.Environment("default",
        bind_resource_id=default_get_networks.ids[0],
        environment_sub_type="ECS",
        environment_type="ECS",
        environment_name=f"{name}-{default_integer['result']}",
        resource_group_id=default.ids[1],
        tags={
            "Created": "TF",
            "For": "Environment",
        })
    ids = alicloud.arms.get_environments_output(ids=[default_environment.id])
    pulumi.export("armsEnvironmentsId0", ids.environments[0].id)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/arms"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
    	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
    	"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
    		}
    		_default, err := resourcemanager.GetResourceGroups(ctx, &resourcemanager.GetResourceGroupsArgs{
    			Status: pulumi.StringRef("OK"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
    			NameRegex: pulumi.StringRef("^default-NODELETING$"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
    			Min: 10000,
    			Max: 99999,
    		})
    		if err != nil {
    			return err
    		}
    		defaultEnvironment, err := arms.NewEnvironment(ctx, "default", &arms.EnvironmentArgs{
    			BindResourceId:     pulumi.String(defaultGetNetworks.Ids[0]),
    			EnvironmentSubType: pulumi.String("ECS"),
    			EnvironmentType:    pulumi.String("ECS"),
    			EnvironmentName:    pulumi.Sprintf("%v-%v", name, defaultInteger.Result),
    			ResourceGroupId:    pulumi.String(_default.Ids[1]),
    			Tags: pulumi.StringMap{
    				"Created": pulumi.String("TF"),
    				"For":     pulumi.String("Environment"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		ids := arms.GetEnvironmentsOutput(ctx, arms.GetEnvironmentsOutputArgs{
    			Ids: pulumi.StringArray{
    				defaultEnvironment.ID(),
    			},
    		}, nil)
    		ctx.Export("armsEnvironmentsId0", ids.ApplyT(func(ids arms.GetEnvironmentsResult) (*string, error) {
    			return &ids.Environments[0].Id, nil
    		}).(pulumi.StringPtrOutput))
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    using Random = Pulumi.Random;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.ResourceManager.GetResourceGroups.Invoke(new()
        {
            Status = "OK",
        });
    
        var defaultGetNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
        {
            NameRegex = "^default-NODELETING$",
        });
    
        var defaultInteger = new Random.Index.Integer("default", new()
        {
            Min = 10000,
            Max = 99999,
        });
    
        var defaultEnvironment = new AliCloud.Arms.Environment("default", new()
        {
            BindResourceId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
            EnvironmentSubType = "ECS",
            EnvironmentType = "ECS",
            EnvironmentName = $"{name}-{defaultInteger.Result}",
            ResourceGroupId = @default.Apply(@default => @default.Apply(getResourceGroupsResult => getResourceGroupsResult.Ids[1])),
            Tags = 
            {
                { "Created", "TF" },
                { "For", "Environment" },
            },
        });
    
        var ids = AliCloud.Arms.GetEnvironments.Invoke(new()
        {
            Ids = new[]
            {
                defaultEnvironment.Id,
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["armsEnvironmentsId0"] = ids.Apply(getEnvironmentsResult => getEnvironmentsResult.Environments[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
    import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
    import com.pulumi.alicloud.vpc.VpcFunctions;
    import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
    import com.pulumi.random.Integer;
    import com.pulumi.random.IntegerArgs;
    import com.pulumi.alicloud.arms.Environment;
    import com.pulumi.alicloud.arms.EnvironmentArgs;
    import com.pulumi.alicloud.arms.ArmsFunctions;
    import com.pulumi.alicloud.arms.inputs.GetEnvironmentsArgs;
    import java.util.List;
    import java.util.ArrayList;
    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");
            final var default = ResourcemanagerFunctions.getResourceGroups(GetResourceGroupsArgs.builder()
                .status("OK")
                .build());
    
            final var defaultGetNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
                .nameRegex("^default-NODELETING$")
                .build());
    
            var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
                .min(10000)
                .max(99999)
                .build());
    
            var defaultEnvironment = new Environment("defaultEnvironment", EnvironmentArgs.builder()
                .bindResourceId(defaultGetNetworks.ids()[0])
                .environmentSubType("ECS")
                .environmentType("ECS")
                .environmentName(String.format("%s-%s", name,defaultInteger.result()))
                .resourceGroupId(default_.ids()[1])
                .tags(Map.ofEntries(
                    Map.entry("Created", "TF"),
                    Map.entry("For", "Environment")
                ))
                .build());
    
            final var ids = ArmsFunctions.getEnvironments(GetEnvironmentsArgs.builder()
                .ids(defaultEnvironment.id())
                .build());
    
            ctx.export("armsEnvironmentsId0", ids.applyValue(_ids -> _ids.environments()[0].id()));
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultInteger:
        type: random:Integer
        name: default
        properties:
          min: 10000
          max: 99999
      defaultEnvironment:
        type: alicloud:arms:Environment
        name: default
        properties:
          bindResourceId: ${defaultGetNetworks.ids[0]}
          environmentSubType: ECS
          environmentType: ECS
          environmentName: ${name}-${defaultInteger.result}
          resourceGroupId: ${default.ids[1]}
          tags:
            Created: TF
            For: Environment
    variables:
      default:
        fn::invoke:
          function: alicloud:resourcemanager:getResourceGroups
          arguments:
            status: OK
      defaultGetNetworks:
        fn::invoke:
          function: alicloud:vpc:getNetworks
          arguments:
            nameRegex: ^default-NODELETING$
      ids:
        fn::invoke:
          function: alicloud:arms:getEnvironments
          arguments:
            ids:
              - ${defaultEnvironment.id}
    outputs:
      armsEnvironmentsId0: ${ids.environments[0].id}
    

    Using getEnvironments

    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 getEnvironments(args: GetEnvironmentsArgs, opts?: InvokeOptions): Promise<GetEnvironmentsResult>
    function getEnvironmentsOutput(args: GetEnvironmentsOutputArgs, opts?: InvokeOptions): Output<GetEnvironmentsResult>
    def get_environments(environment_type: Optional[str] = None,
                         ids: Optional[Sequence[str]] = None,
                         name_regex: Optional[str] = None,
                         output_file: Optional[str] = None,
                         resource_group_id: Optional[str] = None,
                         tags: Optional[Mapping[str, str]] = None,
                         opts: Optional[InvokeOptions] = None) -> GetEnvironmentsResult
    def get_environments_output(environment_type: Optional[pulumi.Input[str]] = None,
                         ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                         name_regex: Optional[pulumi.Input[str]] = None,
                         output_file: Optional[pulumi.Input[str]] = None,
                         resource_group_id: Optional[pulumi.Input[str]] = None,
                         tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetEnvironmentsResult]
    func GetEnvironments(ctx *Context, args *GetEnvironmentsArgs, opts ...InvokeOption) (*GetEnvironmentsResult, error)
    func GetEnvironmentsOutput(ctx *Context, args *GetEnvironmentsOutputArgs, opts ...InvokeOption) GetEnvironmentsResultOutput

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

    public static class GetEnvironments 
    {
        public static Task<GetEnvironmentsResult> InvokeAsync(GetEnvironmentsArgs args, InvokeOptions? opts = null)
        public static Output<GetEnvironmentsResult> Invoke(GetEnvironmentsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetEnvironmentsResult> getEnvironments(GetEnvironmentsArgs args, InvokeOptions options)
    public static Output<GetEnvironmentsResult> getEnvironments(GetEnvironmentsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: alicloud:arms/getEnvironments:getEnvironments
      arguments:
        # arguments dictionary

    The following arguments are supported:

    EnvironmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    Ids List<string>
    A list of ARMS Environment IDs.
    NameRegex string
    A regex string to filter results by ARMS Environment name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ResourceGroupId string
    The ID of the resource group.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    EnvironmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    Ids []string
    A list of ARMS Environment IDs.
    NameRegex string
    A regex string to filter results by ARMS Environment name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ResourceGroupId string
    The ID of the resource group.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    environmentType String
    The environment type. Valid values: CS, ECS, Cloud.
    ids List<String>
    A list of ARMS Environment IDs.
    nameRegex String
    A regex string to filter results by ARMS Environment name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    resourceGroupId String
    The ID of the resource group.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    environmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    ids string[]
    A list of ARMS Environment IDs.
    nameRegex string
    A regex string to filter results by ARMS Environment name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    resourceGroupId string
    The ID of the resource group.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    environment_type str
    The environment type. Valid values: CS, ECS, Cloud.
    ids Sequence[str]
    A list of ARMS Environment IDs.
    name_regex str
    A regex string to filter results by ARMS Environment name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    resource_group_id str
    The ID of the resource group.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    environmentType String
    The environment type. Valid values: CS, ECS, Cloud.
    ids List<String>
    A list of ARMS Environment IDs.
    nameRegex String
    A regex string to filter results by ARMS Environment name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    resourceGroupId String
    The ID of the resource group.
    tags Map<String>
    A mapping of tags to assign to the resource.

    getEnvironments Result

    The following output properties are available:

    Environments List<Pulumi.AliCloud.Arms.Outputs.GetEnvironmentsEnvironment>
    A list of ARMS Environments. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Names List<string>
    A list of ARMS Environment names.
    EnvironmentType string
    The type of the environment instance.
    NameRegex string
    OutputFile string
    ResourceGroupId string
    The ID of the resource group.
    Tags Dictionary<string, string>
    The tags of the environment resource.
    Environments []GetEnvironmentsEnvironment
    A list of ARMS Environments. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Names []string
    A list of ARMS Environment names.
    EnvironmentType string
    The type of the environment instance.
    NameRegex string
    OutputFile string
    ResourceGroupId string
    The ID of the resource group.
    Tags map[string]string
    The tags of the environment resource.
    environments List<GetEnvironmentsEnvironment>
    A list of ARMS Environments. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of ARMS Environment names.
    environmentType String
    The type of the environment instance.
    nameRegex String
    outputFile String
    resourceGroupId String
    The ID of the resource group.
    tags Map<String,String>
    The tags of the environment resource.
    environments GetEnvironmentsEnvironment[]
    A list of ARMS Environments. Each element contains the following attributes:
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    names string[]
    A list of ARMS Environment names.
    environmentType string
    The type of the environment instance.
    nameRegex string
    outputFile string
    resourceGroupId string
    The ID of the resource group.
    tags {[key: string]: string}
    The tags of the environment resource.
    environments Sequence[GetEnvironmentsEnvironment]
    A list of ARMS Environments. Each element contains the following attributes:
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    names Sequence[str]
    A list of ARMS Environment names.
    environment_type str
    The type of the environment instance.
    name_regex str
    output_file str
    resource_group_id str
    The ID of the resource group.
    tags Mapping[str, str]
    The tags of the environment resource.
    environments List<Property Map>
    A list of ARMS Environments. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of ARMS Environment names.
    environmentType String
    The type of the environment instance.
    nameRegex String
    outputFile String
    resourceGroupId String
    The ID of the resource group.
    tags Map<String>
    The tags of the environment resource.

    Supporting Types

    GetEnvironmentsEnvironment

    BindResourceId string
    The ID of the resource bound to the environment instance.
    BindResourceType string
    The resource type.
    BindVpcCidr string
    The CIDR block that is bound to the VPC.
    EnvironmentId string
    The ID of the environment instance.
    EnvironmentName string
    The name of the environment instance.
    EnvironmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    GrafanaDatasourceUid string
    The unique ID of the Grafana data source.
    GrafanaFolderUid string
    The unique ID of the Grafana directory.
    Id string
    The ID of the environment instance.
    ManagedType string
    Indicates whether agents or exporters are managed.
    PrometheusInstanceId string
    The ID of the Prometheus instance.
    RegionId string
    The region ID.
    ResourceGroupId string
    The ID of the resource group.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    UserId string
    The user ID.
    BindResourceId string
    The ID of the resource bound to the environment instance.
    BindResourceType string
    The resource type.
    BindVpcCidr string
    The CIDR block that is bound to the VPC.
    EnvironmentId string
    The ID of the environment instance.
    EnvironmentName string
    The name of the environment instance.
    EnvironmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    GrafanaDatasourceUid string
    The unique ID of the Grafana data source.
    GrafanaFolderUid string
    The unique ID of the Grafana directory.
    Id string
    The ID of the environment instance.
    ManagedType string
    Indicates whether agents or exporters are managed.
    PrometheusInstanceId string
    The ID of the Prometheus instance.
    RegionId string
    The region ID.
    ResourceGroupId string
    The ID of the resource group.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    UserId string
    The user ID.
    bindResourceId String
    The ID of the resource bound to the environment instance.
    bindResourceType String
    The resource type.
    bindVpcCidr String
    The CIDR block that is bound to the VPC.
    environmentId String
    The ID of the environment instance.
    environmentName String
    The name of the environment instance.
    environmentType String
    The environment type. Valid values: CS, ECS, Cloud.
    grafanaDatasourceUid String
    The unique ID of the Grafana data source.
    grafanaFolderUid String
    The unique ID of the Grafana directory.
    id String
    The ID of the environment instance.
    managedType String
    Indicates whether agents or exporters are managed.
    prometheusInstanceId String
    The ID of the Prometheus instance.
    regionId String
    The region ID.
    resourceGroupId String
    The ID of the resource group.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    userId String
    The user ID.
    bindResourceId string
    The ID of the resource bound to the environment instance.
    bindResourceType string
    The resource type.
    bindVpcCidr string
    The CIDR block that is bound to the VPC.
    environmentId string
    The ID of the environment instance.
    environmentName string
    The name of the environment instance.
    environmentType string
    The environment type. Valid values: CS, ECS, Cloud.
    grafanaDatasourceUid string
    The unique ID of the Grafana data source.
    grafanaFolderUid string
    The unique ID of the Grafana directory.
    id string
    The ID of the environment instance.
    managedType string
    Indicates whether agents or exporters are managed.
    prometheusInstanceId string
    The ID of the Prometheus instance.
    regionId string
    The region ID.
    resourceGroupId string
    The ID of the resource group.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    userId string
    The user ID.
    bind_resource_id str
    The ID of the resource bound to the environment instance.
    bind_resource_type str
    The resource type.
    bind_vpc_cidr str
    The CIDR block that is bound to the VPC.
    environment_id str
    The ID of the environment instance.
    environment_name str
    The name of the environment instance.
    environment_type str
    The environment type. Valid values: CS, ECS, Cloud.
    grafana_datasource_uid str
    The unique ID of the Grafana data source.
    grafana_folder_uid str
    The unique ID of the Grafana directory.
    id str
    The ID of the environment instance.
    managed_type str
    Indicates whether agents or exporters are managed.
    prometheus_instance_id str
    The ID of the Prometheus instance.
    region_id str
    The region ID.
    resource_group_id str
    The ID of the resource group.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    user_id str
    The user ID.
    bindResourceId String
    The ID of the resource bound to the environment instance.
    bindResourceType String
    The resource type.
    bindVpcCidr String
    The CIDR block that is bound to the VPC.
    environmentId String
    The ID of the environment instance.
    environmentName String
    The name of the environment instance.
    environmentType String
    The environment type. Valid values: CS, ECS, Cloud.
    grafanaDatasourceUid String
    The unique ID of the Grafana data source.
    grafanaFolderUid String
    The unique ID of the Grafana directory.
    id String
    The ID of the environment instance.
    managedType String
    Indicates whether agents or exporters are managed.
    prometheusInstanceId String
    The ID of the Prometheus instance.
    regionId String
    The region ID.
    resourceGroupId String
    The ID of the resource group.
    tags Map<String>
    A mapping of tags to assign to the resource.
    userId String
    The user ID.

    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
    Alibaba Cloud v3.85.0 published on Tuesday, Sep 9, 2025 by Pulumi