1. Packages
  2. AWS
  3. API Docs
  4. organizations
  5. getOrganizationalUnit
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.organizations.getOrganizationalUnit

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Data source for getting an AWS Organizations Organizational Unit.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const org = aws.organizations.getOrganization({});
    const ou = org.then(org => aws.organizations.getOrganizationalUnit({
        parentId: org.roots?.[0]?.id,
        name: "dev",
    }));
    
    import pulumi
    import pulumi_aws as aws
    
    org = aws.organizations.get_organization()
    ou = aws.organizations.get_organizational_unit(parent_id=org.roots[0].id,
        name="dev")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		org, err := organizations.LookupOrganization(ctx, map[string]interface{}{}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = organizations.LookupOrganizationalUnit(ctx, &organizations.LookupOrganizationalUnitArgs{
    			ParentId: org.Roots[0].Id,
    			Name:     "dev",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var org = Aws.Organizations.GetOrganization.Invoke();
    
        var ou = Aws.Organizations.GetOrganizationalUnit.Invoke(new()
        {
            ParentId = org.Apply(getOrganizationResult => getOrganizationResult.Roots[0]?.Id),
            Name = "dev",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.organizations.OrganizationsFunctions;
    import com.pulumi.aws.organizations.inputs.GetOrganizationalUnitArgs;
    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 org = OrganizationsFunctions.getOrganization();
    
            final var ou = OrganizationsFunctions.getOrganizationalUnit(GetOrganizationalUnitArgs.builder()
                .parentId(org.applyValue(getOrganizationResult -> getOrganizationResult.roots()[0].id()))
                .name("dev")
                .build());
    
        }
    }
    
    variables:
      org:
        fn::invoke:
          Function: aws:organizations:getOrganization
          Arguments: {}
      ou:
        fn::invoke:
          Function: aws:organizations:getOrganizationalUnit
          Arguments:
            parentId: ${org.roots[0].id}
            name: dev
    

    Using getOrganizationalUnit

    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 getOrganizationalUnit(args: GetOrganizationalUnitArgs, opts?: InvokeOptions): Promise<GetOrganizationalUnitResult>
    function getOrganizationalUnitOutput(args: GetOrganizationalUnitOutputArgs, opts?: InvokeOptions): Output<GetOrganizationalUnitResult>
    def get_organizational_unit(name: Optional[str] = None,
                                parent_id: Optional[str] = None,
                                opts: Optional[InvokeOptions] = None) -> GetOrganizationalUnitResult
    def get_organizational_unit_output(name: Optional[pulumi.Input[str]] = None,
                                parent_id: Optional[pulumi.Input[str]] = None,
                                opts: Optional[InvokeOptions] = None) -> Output[GetOrganizationalUnitResult]
    func LookupOrganizationalUnit(ctx *Context, args *LookupOrganizationalUnitArgs, opts ...InvokeOption) (*LookupOrganizationalUnitResult, error)
    func LookupOrganizationalUnitOutput(ctx *Context, args *LookupOrganizationalUnitOutputArgs, opts ...InvokeOption) LookupOrganizationalUnitResultOutput

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

    public static class GetOrganizationalUnit 
    {
        public static Task<GetOrganizationalUnitResult> InvokeAsync(GetOrganizationalUnitArgs args, InvokeOptions? opts = null)
        public static Output<GetOrganizationalUnitResult> Invoke(GetOrganizationalUnitInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetOrganizationalUnitResult> getOrganizationalUnit(GetOrganizationalUnitArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:organizations/getOrganizationalUnit:getOrganizationalUnit
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Name of the organizational unit
    ParentId string
    Parent ID of the organizational unit.
    Name string
    Name of the organizational unit
    ParentId string
    Parent ID of the organizational unit.
    name String
    Name of the organizational unit
    parentId String
    Parent ID of the organizational unit.
    name string
    Name of the organizational unit
    parentId string
    Parent ID of the organizational unit.
    name str
    Name of the organizational unit
    parent_id str
    Parent ID of the organizational unit.
    name String
    Name of the organizational unit
    parentId String
    Parent ID of the organizational unit.

    getOrganizationalUnit Result

    The following output properties are available:

    Arn string
    ARN of the organizational unit
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    ParentId string
    Arn string
    ARN of the organizational unit
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    ParentId string
    arn String
    ARN of the organizational unit
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    parentId String
    arn string
    ARN of the organizational unit
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    parentId string
    arn str
    ARN of the organizational unit
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    parent_id str
    arn String
    ARN of the organizational unit
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    parentId String

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi