1. Packages
  2. Aptible Provider
  3. API Docs
  4. getEnvironment
aptible 0.9.12 published on Monday, Apr 14, 2025 by aptible

aptible.getEnvironment

Explore with Pulumi AI

aptible logo
aptible 0.9.12 published on Monday, Apr 14, 2025 by aptible

    Example Usage

    Determining the Environment ID

    If you have an Environment with the handle “techco-test-environment” you can create the data source:

    import * as pulumi from "@pulumi/pulumi";
    import * as aptible from "@pulumi/aptible";
    
    const techco_test_environment = aptible.getEnvironment({
        handle: "techco-test-environment",
    });
    
    import pulumi
    import pulumi_aptible as aptible
    
    techco_test_environment = aptible.get_environment(handle="techco-test-environment")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/aptible/aptible"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aptible.LookupEnvironment(ctx, &aptible.LookupEnvironmentArgs{
    			Handle: "techco-test-environment",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aptible = Pulumi.Aptible;
    
    return await Deployment.RunAsync(() => 
    {
        var techco_test_environment = Aptible.GetEnvironment.Invoke(new()
        {
            Handle = "techco-test-environment",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aptible.AptibleFunctions;
    import com.pulumi.aptible.inputs.GetEnvironmentArgs;
    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 techco-test-environment = AptibleFunctions.getEnvironment(GetEnvironmentArgs.builder()
                .handle("techco-test-environment")
                .build());
    
        }
    }
    
    variables:
      techco-test-environment:
        fn::invoke:
          function: aptible:getEnvironment
          arguments:
            handle: techco-test-environment
    

    Once defined, you can use this data source in your resource definitions. For example, when defining an App:

    import * as pulumi from "@pulumi/pulumi";
    import * as aptible from "@pulumi/aptible";
    
    const techco_app = new aptible.App("techco-app", {
        envId: data.aptible_environment["techco-test-environment"].env_id,
        handle: "techco-app",
    });
    
    import pulumi
    import pulumi_aptible as aptible
    
    techco_app = aptible.App("techco-app",
        env_id=data["aptible_environment"]["techco-test-environment"]["env_id"],
        handle="techco-app")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/aptible/aptible"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aptible.NewApp(ctx, "techco-app", &aptible.AppArgs{
    			EnvId:  pulumi.Any(data.Aptible_environment.TechcoTestEnvironment.Env_id),
    			Handle: pulumi.String("techco-app"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aptible = Pulumi.Aptible;
    
    return await Deployment.RunAsync(() => 
    {
        var techco_app = new Aptible.App("techco-app", new()
        {
            EnvId = data.Aptible_environment.Techco_test_environment.Env_id,
            Handle = "techco-app",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aptible.App;
    import com.pulumi.aptible.AppArgs;
    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) {
            var techco_app = new App("techco-app", AppArgs.builder()
                .envId(data.aptible_environment().techco-test-environment().env_id())
                .handle("techco-app")
                .build());
    
        }
    }
    
    resources:
      techco-app:
        type: aptible:App
        properties:
          envId: ${data.aptible_environment"techco-test-environment"[%!s(MISSING)].env_id}
          handle: techco-app
    

    Using getEnvironment

    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 getEnvironment(args: GetEnvironmentArgs, opts?: InvokeOptions): Promise<GetEnvironmentResult>
    function getEnvironmentOutput(args: GetEnvironmentOutputArgs, opts?: InvokeOptions): Output<GetEnvironmentResult>
    def get_environment(handle: Optional[str] = None,
                        id: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetEnvironmentResult
    def get_environment_output(handle: Optional[pulumi.Input[str]] = None,
                        id: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetEnvironmentResult]
    func LookupEnvironment(ctx *Context, args *LookupEnvironmentArgs, opts ...InvokeOption) (*LookupEnvironmentResult, error)
    func LookupEnvironmentOutput(ctx *Context, args *LookupEnvironmentOutputArgs, opts ...InvokeOption) LookupEnvironmentResultOutput

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

    public static class GetEnvironment 
    {
        public static Task<GetEnvironmentResult> InvokeAsync(GetEnvironmentArgs args, InvokeOptions? opts = null)
        public static Output<GetEnvironmentResult> Invoke(GetEnvironmentInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetEnvironmentResult> getEnvironment(GetEnvironmentArgs args, InvokeOptions options)
    public static Output<GetEnvironmentResult> getEnvironment(GetEnvironmentArgs args, InvokeOptions options)
    
    fn::invoke:
      function: aptible:index/getEnvironment:getEnvironment
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Handle string
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    Id string
    Handle string
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    Id string
    handle String
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    id String
    handle string
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    id string
    handle str
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    id str
    handle String
    The handle for the Environment. This must be all lower case, and only contain letters, numbers, -, _, or .
    id String

    getEnvironment Result

    The following output properties are available:

    EnvId double
    The unique ID for an Environment suitable for use in env_id attributes
    Handle string
    Id string
    EnvId float64
    The unique ID for an Environment suitable for use in env_id attributes
    Handle string
    Id string
    envId Double
    The unique ID for an Environment suitable for use in env_id attributes
    handle String
    id String
    envId number
    The unique ID for an Environment suitable for use in env_id attributes
    handle string
    id string
    env_id float
    The unique ID for an Environment suitable for use in env_id attributes
    handle str
    id str
    envId Number
    The unique ID for an Environment suitable for use in env_id attributes
    handle String
    id String

    Package Details

    Repository
    aptible aptible/terraform-provider-aptible
    License
    Notes
    This Pulumi package is based on the aptible Terraform Provider.
    aptible logo
    aptible 0.9.12 published on Monday, Apr 14, 2025 by aptible