Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi
alicloud.resourcemanager.getSharedTargets
Explore with Pulumi AI
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.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - string
- The resource share ID of resource manager.
- Status string
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
- Ids []string
- A list of Shared Target IDs.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - string
- The resource share ID of resource manager.
- Status string
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
- ids List<String>
- A list of Shared Target IDs.
- output
File String - File name where to save data source results (after running
pulumi preview
). - String
- The resource share ID of resource manager.
- status String
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
- ids string[]
- A list of Shared Target IDs.
- output
File string - File name where to save data source results (after running
pulumi preview
). - string
- The resource share ID of resource manager.
- status string
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
- ids Sequence[str]
- A list of Shared Target IDs.
- output_
file str - File name where to save data source results (after running
pulumi preview
). - str
- The resource share ID of resource manager.
- status str
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
- ids List<String>
- A list of Shared Target IDs.
- output
File String - File name where to save data source results (after running
pulumi preview
). - String
- The resource share ID of resource manager.
- status String
- The status of share resource. Valid values:
Associated
,Associating
,Disassociated
,Disassociating
andFailed
.
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.
Ali Cloud. Resource Manager. Outputs. Get Shared Targets Target> - A list of Resource Manager Shared Targets. Each element contains the following attributes:
- Output
File string - 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
[]Get
Shared Targets Target - A list of Resource Manager Shared Targets. Each element contains the following attributes:
- Output
File string - 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<Get
Shared Targets Target> - A list of Resource Manager Shared Targets. Each element contains the following attributes:
- output
File String - 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
Get
Shared Targets Target[] - A list of Resource Manager Shared Targets. Each element contains the following attributes:
- output
File string - 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[Get
Shared Targets Target] - A list of Resource Manager Shared Targets. Each element contains the following attributes:
- output_
file str - 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:
- output
File String - String
- The resource shared ID of resource manager.
- status String
- The status of shared target.
Supporting Types
GetSharedTargetsTarget
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.