1. Packages
  2. Packages
  3. Dynatrace
  4. API Docs
  5. getIamEnvironments
Viewing docs for Dynatrace v0.37.0
published on Tuesday, Jun 23, 2026 by Pulumiverse
dynatrace logo
Viewing docs for Dynatrace v0.37.0
published on Tuesday, Jun 23, 2026 by Pulumiverse

    Dynatrace SaaS only

    To utilize this data source, please define the environment variables DT_CLIENT_ID, DT_CLIENT_SECRET, and DT_ACCOUNT_ID with an OAuth client including the following permission: View environments (account-env-read).

    This data source allows you to query the environments in a Dynatrace account and filter them by their active status, id, or name.

    Example Usage

    Query active environments

    import * as pulumi from "@pulumi/pulumi";
    import * as dynatrace from "@pulumiverse/dynatrace";
    
    export = async () => {
        const activeEnvironments = await dynatrace.getIamEnvironments({
            active: true,
        });
        return {
            activeEnvironments: activeEnvironments.environments.map(__item => __item.id),
        };
    }
    
    import pulumi
    import pulumi_dynatrace as dynatrace
    
    active_environments = dynatrace.get_iam_environments(active=True)
    pulumi.export("activeEnvironments", [__item.id for __item in active_environments.environments])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-dynatrace/sdk/go/dynatrace"
    )
    func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    activeEnvironments, err := dynatrace.GetIamEnvironments(ctx, &dynatrace.GetIamEnvironmentsArgs{
    Active: pulumi.BoolRef(true),
    }, nil);
    if err != nil {
    return err
    }
    ctx.Export("activeEnvironments", pulumi.StringArray(%!v(PANIC=Format method: fatal: A failure has occurred: unlowered splat expression @ example.pp:5,11-48)))
    return nil
    })
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Dynatrace = Pulumiverse.Dynatrace;
    
    return await Deployment.RunAsync(() => 
    {
        var activeEnvironments = Dynatrace.GetIamEnvironments.Invoke(new()
        {
            Active = true,
        });
    
        return new Dictionary<string, object?>
        {
            ["activeEnvironments"] = activeEnvironments.Apply(getIamEnvironmentsResult => getIamEnvironmentsResult.Environments).Select(__item => __item.Id).ToList(),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.dynatrace.DynatraceFunctions;
    import com.pulumi.dynatrace.inputs.GetIamEnvironmentsArgs;
    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 activeEnvironments = DynatraceFunctions.getIamEnvironments(GetIamEnvironmentsArgs.builder()
                .active(true)
                .build());
    
            ctx.export("activeEnvironments", activeEnvironments.environments().stream().map(element -> element.id()).collect(toList()));
        }
    }
    
    Example coming soon!
    
    pulumi {
      required_providers {
        dynatrace = {
          source = "pulumi/dynatrace"
        }
      }
    }
    
    data "dynatrace_getiamenvironments" "activeEnvironments" {
      active = true
    }
    
    output "activeEnvironments" {
      value = data.dynatrace_getiamenvironments.activeEnvironments.environments[*].id
    }
    

    Query environment by name

    import * as pulumi from "@pulumi/pulumi";
    import * as dynatrace from "@pulumiverse/dynatrace";
    
    const byName = dynatrace.getIamEnvironments({
        name: "production",
    });
    export const environmentId = byName.then(byName => byName.environments?.[0]?.id);
    
    import pulumi
    import pulumi_dynatrace as dynatrace
    
    by_name = dynatrace.get_iam_environments(name="production")
    pulumi.export("environmentId", by_name.environments[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-dynatrace/sdk/go/dynatrace"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		byName, err := dynatrace.GetIamEnvironments(ctx, &dynatrace.GetIamEnvironmentsArgs{
    			Name: pulumi.StringRef("production"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("environmentId", byName.Environments[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Dynatrace = Pulumiverse.Dynatrace;
    
    return await Deployment.RunAsync(() => 
    {
        var byName = Dynatrace.GetIamEnvironments.Invoke(new()
        {
            Name = "production",
        });
    
        return new Dictionary<string, object?>
        {
            ["environmentId"] = byName.Apply(getIamEnvironmentsResult => getIamEnvironmentsResult.Environments[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.dynatrace.DynatraceFunctions;
    import com.pulumi.dynatrace.inputs.GetIamEnvironmentsArgs;
    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 byName = DynatraceFunctions.getIamEnvironments(GetIamEnvironmentsArgs.builder()
                .name("production")
                .build());
    
            ctx.export("environmentId", byName.environments()[0].id());
        }
    }
    
    variables:
      byName:
        fn::invoke:
          function: dynatrace:getIamEnvironments
          arguments:
            name: production
    outputs:
      environmentId: ${byName.environments[0].id}
    
    pulumi {
      required_providers {
        dynatrace = {
          source = "pulumi/dynatrace"
        }
      }
    }
    
    data "dynatrace_getiamenvironments" "byName" {
      name = "production"
    }
    
    output "environmentId" {
      value = data.dynatrace_getiamenvironments.byName.environments[0].id
    }
    

    Using getIamEnvironments

    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 getIamEnvironments(args: GetIamEnvironmentsArgs, opts?: InvokeOptions): Promise<GetIamEnvironmentsResult>
    function getIamEnvironmentsOutput(args: GetIamEnvironmentsOutputArgs, opts?: InvokeOptions): Output<GetIamEnvironmentsResult>
    def get_iam_environments(active: Optional[bool] = None,
                             env_id: Optional[str] = None,
                             name: Optional[str] = None,
                             opts: Optional[InvokeOptions] = None) -> GetIamEnvironmentsResult
    def get_iam_environments_output(active: pulumi.Input[Optional[bool]] = None,
                             env_id: pulumi.Input[Optional[str]] = None,
                             name: pulumi.Input[Optional[str]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetIamEnvironmentsResult]
    func GetIamEnvironments(ctx *Context, args *GetIamEnvironmentsArgs, opts ...InvokeOption) (*GetIamEnvironmentsResult, error)
    func GetIamEnvironmentsOutput(ctx *Context, args *GetIamEnvironmentsOutputArgs, opts ...InvokeOption) GetIamEnvironmentsResultOutput

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

    public static class GetIamEnvironments 
    {
        public static Task<GetIamEnvironmentsResult> InvokeAsync(GetIamEnvironmentsArgs args, InvokeOptions? opts = null)
        public static Output<GetIamEnvironmentsResult> Invoke(GetIamEnvironmentsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetIamEnvironmentsResult> getIamEnvironments(GetIamEnvironmentsArgs args, InvokeOptions options)
    public static Output<GetIamEnvironmentsResult> getIamEnvironments(GetIamEnvironmentsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: dynatrace:index/getIamEnvironments:getIamEnvironments
      arguments:
        # arguments dictionary
    data "dynatrace_getiamenvironments" "name" {
        # arguments
    }

    The following arguments are supported:

    Active bool
    Filter by active status of the environment
    EnvId string
    Filter by ID of the environment
    Name string
    Filter by friendly name of the environment
    Active bool
    Filter by active status of the environment
    EnvId string
    Filter by ID of the environment
    Name string
    Filter by friendly name of the environment
    active bool
    Filter by active status of the environment
    env_id string
    Filter by ID of the environment
    name string
    Filter by friendly name of the environment
    active Boolean
    Filter by active status of the environment
    envId String
    Filter by ID of the environment
    name String
    Filter by friendly name of the environment
    active boolean
    Filter by active status of the environment
    envId string
    Filter by ID of the environment
    name string
    Filter by friendly name of the environment
    active bool
    Filter by active status of the environment
    env_id str
    Filter by ID of the environment
    name str
    Filter by friendly name of the environment
    active Boolean
    Filter by active status of the environment
    envId String
    Filter by ID of the environment
    name String
    Filter by friendly name of the environment

    getIamEnvironments Result

    The following output properties are available:

    Environments List<Pulumiverse.Dynatrace.Outputs.GetIamEnvironmentsEnvironment>
    List of environments matching the filter criteria
    Id string
    The provider-assigned unique ID for this managed resource.
    Active bool
    Filter by active status of the environment
    EnvId string
    Filter by ID of the environment
    Name string
    Filter by friendly name of the environment
    Environments []GetIamEnvironmentsEnvironment
    List of environments matching the filter criteria
    Id string
    The provider-assigned unique ID for this managed resource.
    Active bool
    Filter by active status of the environment
    EnvId string
    Filter by ID of the environment
    Name string
    Filter by friendly name of the environment
    environments list(object)
    List of environments matching the filter criteria
    id string
    The provider-assigned unique ID for this managed resource.
    active bool
    Filter by active status of the environment
    env_id string
    Filter by ID of the environment
    name string
    Filter by friendly name of the environment
    environments List<GetIamEnvironmentsEnvironment>
    List of environments matching the filter criteria
    id String
    The provider-assigned unique ID for this managed resource.
    active Boolean
    Filter by active status of the environment
    envId String
    Filter by ID of the environment
    name String
    Filter by friendly name of the environment
    environments GetIamEnvironmentsEnvironment[]
    List of environments matching the filter criteria
    id string
    The provider-assigned unique ID for this managed resource.
    active boolean
    Filter by active status of the environment
    envId string
    Filter by ID of the environment
    name string
    Filter by friendly name of the environment
    environments Sequence[GetIamEnvironmentsEnvironment]
    List of environments matching the filter criteria
    id str
    The provider-assigned unique ID for this managed resource.
    active bool
    Filter by active status of the environment
    env_id str
    Filter by ID of the environment
    name str
    Filter by friendly name of the environment
    environments List<Property Map>
    List of environments matching the filter criteria
    id String
    The provider-assigned unique ID for this managed resource.
    active Boolean
    Filter by active status of the environment
    envId String
    Filter by ID of the environment
    name String
    Filter by friendly name of the environment

    Supporting Types

    GetIamEnvironmentsEnvironment

    Active bool
    Property to determine if environment is active
    Id string
    The ID of the environment
    Name string
    Friendly name of the environment
    Url string
    The URL of the environment
    Active bool
    Property to determine if environment is active
    Id string
    The ID of the environment
    Name string
    Friendly name of the environment
    Url string
    The URL of the environment
    active bool
    Property to determine if environment is active
    id string
    The ID of the environment
    name string
    Friendly name of the environment
    url string
    The URL of the environment
    active Boolean
    Property to determine if environment is active
    id String
    The ID of the environment
    name String
    Friendly name of the environment
    url String
    The URL of the environment
    active boolean
    Property to determine if environment is active
    id string
    The ID of the environment
    name string
    Friendly name of the environment
    url string
    The URL of the environment
    active bool
    Property to determine if environment is active
    id str
    The ID of the environment
    name str
    Friendly name of the environment
    url str
    The URL of the environment
    active Boolean
    Property to determine if environment is active
    id String
    The ID of the environment
    name String
    Friendly name of the environment
    url String
    The URL of the environment

    Package Details

    Repository
    dynatrace pulumiverse/pulumi-dynatrace
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the dynatrace Terraform Provider.
    dynatrace logo
    Viewing docs for Dynatrace v0.37.0
    published on Tuesday, Jun 23, 2026 by Pulumiverse

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial