1. Packages
  2. Alicloud Provider
  3. API Docs
  4. resourcemanager
  5. getSharedTargets
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

alicloud.resourcemanager.getSharedTargets

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

    This data source provides the Resource Manager Shared Targets of the current Alibaba Cloud user.

    NOTE: Available since v1.111.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") || "tf-example";
    const default = alicloud.resourcemanager.getAccounts({});
    const defaultResourceShare = new alicloud.resourcemanager.ResourceShare("default", {resourceShareName: name});
    const defaultSharedTarget = new alicloud.resourcemanager.SharedTarget("default", {
        resourceShareId: defaultResourceShare.id,
        targetId: _default.then(_default => _default.ids?.[0]),
    });
    const ids = alicloud.resourcemanager.getSharedTargetsOutput({
        ids: [defaultSharedTarget.targetId],
    });
    export const firstResourceManagerSharedTargetId = ids.apply(ids => ids.targets?.[0]?.id);
    const resourceShareId = alicloud.resourcemanager.getSharedTargetsOutput({
        resourceShareId: defaultSharedTarget.resourceShareId,
    });
    export const secondResourceManagerSharedTargetId = resourceShareId.apply(resourceShareId => resourceShareId.targets?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf-example"
    default = alicloud.resourcemanager.get_accounts()
    default_resource_share = alicloud.resourcemanager.ResourceShare("default", resource_share_name=name)
    default_shared_target = alicloud.resourcemanager.SharedTarget("default",
        resource_share_id=default_resource_share.id,
        target_id=default.ids[0])
    ids = alicloud.resourcemanager.get_shared_targets_output(ids=[default_shared_target.target_id])
    pulumi.export("firstResourceManagerSharedTargetId", ids.targets[0].id)
    resource_share_id = alicloud.resourcemanager.get_shared_targets_output(resource_share_id=default_shared_target.resource_share_id)
    pulumi.export("secondResourceManagerSharedTargetId", resource_share_id.targets[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"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 := "tf-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := resourcemanager.GetAccounts(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultResourceShare, err := resourcemanager.NewResourceShare(ctx, "default", &resourcemanager.ResourceShareArgs{
    			ResourceShareName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSharedTarget, err := resourcemanager.NewSharedTarget(ctx, "default", &resourcemanager.SharedTargetArgs{
    			ResourceShareId: defaultResourceShare.ID(),
    			TargetId:        pulumi.String(_default.Ids[0]),
    		})
    		if err != nil {
    			return err
    		}
    		ids := resourcemanager.GetSharedTargetsOutput(ctx, resourcemanager.GetSharedTargetsOutputArgs{
    			Ids: pulumi.StringArray{
    				defaultSharedTarget.TargetId,
    			},
    		}, nil)
    		ctx.Export("firstResourceManagerSharedTargetId", ids.ApplyT(func(ids resourcemanager.GetSharedTargetsResult) (*string, error) {
    			return &ids.Targets[0].Id, nil
    		}).(pulumi.StringPtrOutput))
    		resourceShareId := resourcemanager.GetSharedTargetsOutput(ctx, resourcemanager.GetSharedTargetsOutputArgs{
    			ResourceShareId: defaultSharedTarget.ResourceShareId,
    		}, nil)
    		ctx.Export("secondResourceManagerSharedTargetId", resourceShareId.ApplyT(func(resourceShareId resourcemanager.GetSharedTargetsResult) (*string, error) {
    			return &resourceShareId.Targets[0].Id, nil
    		}).(pulumi.StringPtrOutput))
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "tf-example";
        var @default = AliCloud.ResourceManager.GetAccounts.Invoke();
    
        var defaultResourceShare = new AliCloud.ResourceManager.ResourceShare("default", new()
        {
            ResourceShareName = name,
        });
    
        var defaultSharedTarget = new AliCloud.ResourceManager.SharedTarget("default", new()
        {
            ResourceShareId = defaultResourceShare.Id,
            TargetId = @default.Apply(@default => @default.Apply(getAccountsResult => getAccountsResult.Ids[0])),
        });
    
        var ids = AliCloud.ResourceManager.GetSharedTargets.Invoke(new()
        {
            Ids = new[]
            {
                defaultSharedTarget.TargetId,
            },
        });
    
        var resourceShareId = AliCloud.ResourceManager.GetSharedTargets.Invoke(new()
        {
            ResourceShareId = defaultSharedTarget.ResourceShareId,
        });
    
        return new Dictionary<string, object?>
        {
            ["firstResourceManagerSharedTargetId"] = ids.Apply(getSharedTargetsResult => getSharedTargetsResult.Targets[0]?.Id),
            ["secondResourceManagerSharedTargetId"] = resourceShareId.Apply(getSharedTargetsResult => getSharedTargetsResult.Targets[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.GetAccountsArgs;
    import com.pulumi.alicloud.resourcemanager.ResourceShare;
    import com.pulumi.alicloud.resourcemanager.ResourceShareArgs;
    import com.pulumi.alicloud.resourcemanager.SharedTarget;
    import com.pulumi.alicloud.resourcemanager.SharedTargetArgs;
    import com.pulumi.alicloud.resourcemanager.inputs.GetSharedTargetsArgs;
    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("tf-example");
            final var default = ResourcemanagerFunctions.getAccounts();
    
            var defaultResourceShare = new ResourceShare("defaultResourceShare", ResourceShareArgs.builder()
                .resourceShareName(name)
                .build());
    
            var defaultSharedTarget = new SharedTarget("defaultSharedTarget", SharedTargetArgs.builder()
                .resourceShareId(defaultResourceShare.id())
                .targetId(default_.ids()[0])
                .build());
    
            final var ids = ResourcemanagerFunctions.getSharedTargets(GetSharedTargetsArgs.builder()
                .ids(defaultSharedTarget.targetId())
                .build());
    
            ctx.export("firstResourceManagerSharedTargetId", ids.applyValue(getSharedTargetsResult -> getSharedTargetsResult).applyValue(ids -> ids.applyValue(getSharedTargetsResult -> getSharedTargetsResult.targets()[0].id())));
            final var resourceShareId = ResourcemanagerFunctions.getSharedTargets(GetSharedTargetsArgs.builder()
                .resourceShareId(defaultSharedTarget.resourceShareId())
                .build());
    
            ctx.export("secondResourceManagerSharedTargetId", resourceShareId.applyValue(getSharedTargetsResult -> getSharedTargetsResult).applyValue(resourceShareId -> resourceShareId.applyValue(getSharedTargetsResult -> getSharedTargetsResult.targets()[0].id())));
        }
    }
    
    configuration:
      name:
        type: string
        default: tf-example
    resources:
      defaultResourceShare:
        type: alicloud:resourcemanager:ResourceShare
        name: default
        properties:
          resourceShareName: ${name}
      defaultSharedTarget:
        type: alicloud:resourcemanager:SharedTarget
        name: default
        properties:
          resourceShareId: ${defaultResourceShare.id}
          targetId: ${default.ids[0]}
    variables:
      default:
        fn::invoke:
          Function: alicloud:resourcemanager:getAccounts
          Arguments: {}
      ids:
        fn::invoke:
          Function: alicloud:resourcemanager:getSharedTargets
          Arguments:
            ids:
              - ${defaultSharedTarget.targetId}
      resourceShareId:
        fn::invoke:
          Function: alicloud:resourcemanager:getSharedTargets
          Arguments:
            resourceShareId: ${defaultSharedTarget.resourceShareId}
    outputs:
      firstResourceManagerSharedTargetId: ${ids.targets[0].id}
      secondResourceManagerSharedTargetId: ${resourceShareId.targets[0].id}
    

    Using getSharedTargets

    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 getSharedTargets(args: GetSharedTargetsArgs, opts?: InvokeOptions): Promise<GetSharedTargetsResult>
    function getSharedTargetsOutput(args: GetSharedTargetsOutputArgs, opts?: InvokeOptions): Output<GetSharedTargetsResult>
    def get_shared_targets(ids: Optional[Sequence[str]] = None,
                           output_file: Optional[str] = None,
                           resource_share_id: Optional[str] = None,
                           status: Optional[str] = None,
                           opts: Optional[InvokeOptions] = None) -> GetSharedTargetsResult
    def get_shared_targets_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           output_file: Optional[pulumi.Input[str]] = None,
                           resource_share_id: Optional[pulumi.Input[str]] = None,
                           status: Optional[pulumi.Input[str]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetSharedTargetsResult]
    func GetSharedTargets(ctx *Context, args *GetSharedTargetsArgs, opts ...InvokeOption) (*GetSharedTargetsResult, error)
    func GetSharedTargetsOutput(ctx *Context, args *GetSharedTargetsOutputArgs, opts ...InvokeOption) GetSharedTargetsResultOutput

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

    public static class GetSharedTargets 
    {
        public static Task<GetSharedTargetsResult> InvokeAsync(GetSharedTargetsArgs args, InvokeOptions? opts = null)
        public static Output<GetSharedTargetsResult> Invoke(GetSharedTargetsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSharedTargetsResult> getSharedTargets(GetSharedTargetsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:resourcemanager/getSharedTargets:getSharedTargets
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Ids List<string>
    A list of Shared Target IDs.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ResourceShareId string
    The resource share ID of resource manager.
    Status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    Ids []string
    A list of Shared Target IDs.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ResourceShareId string
    The resource share ID of resource manager.
    Status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    ids List<String>
    A list of Shared Target IDs.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    resourceShareId String
    The resource share ID of resource manager.
    status String
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    ids string[]
    A list of Shared Target IDs.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    resourceShareId string
    The resource share ID of resource manager.
    status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    ids Sequence[str]
    A list of Shared Target IDs.
    output_file str
    File name where to save data source results (after running pulumi preview).
    resource_share_id str
    The resource share ID of resource manager.
    status str
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    ids List<String>
    A list of Shared Target IDs.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    resourceShareId String
    The resource share ID of resource manager.
    status String
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.

    getSharedTargets Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Targets List<Pulumi.AliCloud.ResourceManager.Outputs.GetSharedTargetsTarget>
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    OutputFile string
    ResourceShareId string
    The resource shared ID of resource manager.
    Status string
    The status of shared target.
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Targets []GetSharedTargetsTarget
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    OutputFile string
    ResourceShareId string
    The resource shared ID of resource manager.
    Status string
    The status of shared target.
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    targets List<GetSharedTargetsTarget>
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    outputFile String
    resourceShareId String
    The resource shared ID of resource manager.
    status String
    The status of shared target.
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    targets GetSharedTargetsTarget[]
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    outputFile string
    resourceShareId string
    The resource shared ID of resource manager.
    status string
    The status of shared target.
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    targets Sequence[GetSharedTargetsTarget]
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    output_file str
    resource_share_id str
    The resource shared ID of resource manager.
    status str
    The status of shared target.
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    targets List<Property Map>
    A list of Resource Manager Shared Targets. Each element contains the following attributes:
    outputFile String
    resourceShareId String
    The resource shared ID of resource manager.
    status String
    The status of shared target.

    Supporting Types

    GetSharedTargetsTarget

    Id string
    The ID of the Shared Target.
    ResourceShareId string
    The resource share ID of resource manager.
    Status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    TargetId string
    The ID of the Shared Target.
    Id string
    The ID of the Shared Target.
    ResourceShareId string
    The resource share ID of resource manager.
    Status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    TargetId string
    The ID of the Shared Target.
    id String
    The ID of the Shared Target.
    resourceShareId String
    The resource share ID of resource manager.
    status String
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    targetId String
    The ID of the Shared Target.
    id string
    The ID of the Shared Target.
    resourceShareId string
    The resource share ID of resource manager.
    status string
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    targetId string
    The ID of the Shared Target.
    id str
    The ID of the Shared Target.
    resource_share_id str
    The resource share ID of resource manager.
    status str
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    target_id str
    The ID of the Shared Target.
    id String
    The ID of the Shared Target.
    resourceShareId String
    The resource share ID of resource manager.
    status String
    The status of share resource. Valid values: Associated, Associating, Disassociated, Disassociating and Failed.
    targetId String
    The ID of the Shared Target.

    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.62.1 published on Monday, Sep 16, 2024 by Pulumi