Alibaba Cloud v3.88.0 published on Saturday, Nov 1, 2025 by Pulumi
alicloud.resourcemanager.getSharedResources
Start a Neo task
Explain and create an alicloud.resourcemanager.getSharedResources resource
This data source provides the Resource Manager Shared Resources 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";
import * as std from "@pulumi/std";
const config = new pulumi.Config();
const name = config.get("name") || "tf-example";
const _default = alicloud.getZones({
availableResourceCreation: "VSwitch",
});
const defaultGetNetworks = alicloud.vpc.getNetworks({
nameRegex: "^default-NODELETING$",
});
const defaultGetSwitches = Promise.all([defaultGetNetworks, _default]).then(([defaultGetNetworks, _default]) => alicloud.vpc.getSwitches({
vpcId: defaultGetNetworks.ids?.[0],
zoneId: _default.ids?.[0],
}));
const defaultResourceShare = new alicloud.resourcemanager.ResourceShare("default", {resourceShareName: name});
const defaultSharedResource = new alicloud.resourcemanager.SharedResource("default", {
resourceShareId: defaultResourceShare.id,
resourceId: defaultGetSwitches.then(defaultGetSwitches => defaultGetSwitches.ids?.[0]),
resourceType: "VSwitch",
});
const ids = std.format({
input: "%s:%s",
args: [
defaultSharedResource.resourceId,
defaultSharedResource.resourceType,
],
}).then(invoke => alicloud.resourcemanager.getSharedResources({
ids: [invoke.result],
}));
export const firstResourceManagerSharedResourceId = ids.then(ids => ids.resources?.[0]?.id);
const resourceShareId = alicloud.resourcemanager.getSharedResourcesOutput({
resourceShareId: defaultSharedResource.resourceShareId,
});
export const secondResourceManagerSharedResourceId = resourceShareId.apply(resourceShareId => resourceShareId.resources?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
import pulumi_std as std
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example"
default = alicloud.get_zones(available_resource_creation="VSwitch")
default_get_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
default_get_switches = alicloud.vpc.get_switches(vpc_id=default_get_networks.ids[0],
zone_id=default.ids[0])
default_resource_share = alicloud.resourcemanager.ResourceShare("default", resource_share_name=name)
default_shared_resource = alicloud.resourcemanager.SharedResource("default",
resource_share_id=default_resource_share.id,
resource_id=default_get_switches.ids[0],
resource_type="VSwitch")
ids = alicloud.resourcemanager.get_shared_resources(ids=[std.format(input="%s:%s",
args=[
default_shared_resource.resource_id,
default_shared_resource.resource_type,
]).result])
pulumi.export("firstResourceManagerSharedResourceId", ids.resources[0].id)
resource_share_id = alicloud.resourcemanager.get_shared_resources_output(resource_share_id=default_shared_resource.resource_share_id)
pulumi.export("secondResourceManagerSharedResourceId", resource_share_id.resources[0].id)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi-std/sdk/go/std"
"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 := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil);
if err != nil {
return err
}
defaultGetNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
NameRegex: pulumi.StringRef("^default-NODELETING$"),
}, nil);
if err != nil {
return err
}
defaultGetSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
VpcId: pulumi.StringRef(defaultGetNetworks.Ids[0]),
ZoneId: pulumi.StringRef(_default.Ids[0]),
}, nil);
if err != nil {
return err
}
defaultResourceShare, err := resourcemanager.NewResourceShare(ctx, "default", &resourcemanager.ResourceShareArgs{
ResourceShareName: pulumi.String(name),
})
if err != nil {
return err
}
defaultSharedResource, err := resourcemanager.NewSharedResource(ctx, "default", &resourcemanager.SharedResourceArgs{
ResourceShareId: defaultResourceShare.ID(),
ResourceId: pulumi.String(defaultGetSwitches.Ids[0]),
ResourceType: pulumi.String("VSwitch"),
})
if err != nil {
return err
}
ids, err := resourcemanager.GetSharedResources(ctx, &resourcemanager.GetSharedResourcesArgs{
Ids: interface{}{
std.Format(ctx, &std.FormatArgs{
Input: "%s:%s",
Args: pulumi.StringArray{
defaultSharedResource.ResourceId,
defaultSharedResource.ResourceType,
},
}, nil).Result,
},
}, nil);
if err != nil {
return err
}
ctx.Export("firstResourceManagerSharedResourceId", ids.Resources[0].Id)
resourceShareId := resourcemanager.GetSharedResourcesOutput(ctx, resourcemanager.GetSharedResourcesOutputArgs{
ResourceShareId: defaultSharedResource.ResourceShareId,
}, nil);
ctx.Export("secondResourceManagerSharedResourceId", resourceShareId.ApplyT(func(resourceShareId resourcemanager.GetSharedResourcesResult) (*string, error) {
return &resourceShareId.Resources[0].Id, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "tf-example";
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableResourceCreation = "VSwitch",
});
var defaultGetNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
{
NameRegex = "^default-NODELETING$",
});
var defaultGetSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
{
VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
ZoneId = @default.Apply(getZonesResult => getZonesResult.Ids[0]),
});
var defaultResourceShare = new AliCloud.ResourceManager.ResourceShare("default", new()
{
ResourceShareName = name,
});
var defaultSharedResource = new AliCloud.ResourceManager.SharedResource("default", new()
{
ResourceShareId = defaultResourceShare.Id,
ResourceId = defaultGetSwitches.Apply(getSwitchesResult => getSwitchesResult.Ids[0]),
ResourceType = "VSwitch",
});
var ids = AliCloud.ResourceManager.GetSharedResources.Invoke(new()
{
Ids = new[]
{
Std.Format.Invoke(new()
{
Input = "%s:%s",
Args = new[]
{
defaultSharedResource.ResourceId,
defaultSharedResource.ResourceType,
},
}).Result,
},
});
var resourceShareId = AliCloud.ResourceManager.GetSharedResources.Invoke(new()
{
ResourceShareId = defaultSharedResource.ResourceShareId,
});
return new Dictionary<string, object?>
{
["firstResourceManagerSharedResourceId"] = ids.Apply(getSharedResourcesResult => getSharedResourcesResult.Resources[0]?.Id),
["secondResourceManagerSharedResourceId"] = resourceShareId.Apply(getSharedResourcesResult => getSharedResourcesResult.Resources[0]?.Id),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
import com.pulumi.alicloud.resourcemanager.ResourceShare;
import com.pulumi.alicloud.resourcemanager.ResourceShareArgs;
import com.pulumi.alicloud.resourcemanager.SharedResource;
import com.pulumi.alicloud.resourcemanager.SharedResourceArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FormatArgs;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetSharedResourcesArgs;
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 = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
final var defaultGetNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
.nameRegex("^default-NODELETING$")
.build());
final var defaultGetSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
.vpcId(defaultGetNetworks.ids()[0])
.zoneId(default_.ids()[0])
.build());
var defaultResourceShare = new ResourceShare("defaultResourceShare", ResourceShareArgs.builder()
.resourceShareName(name)
.build());
var defaultSharedResource = new SharedResource("defaultSharedResource", SharedResourceArgs.builder()
.resourceShareId(defaultResourceShare.id())
.resourceId(defaultGetSwitches.ids()[0])
.resourceType("VSwitch")
.build());
final var ids = ResourcemanagerFunctions.getSharedResources(GetSharedResourcesArgs.builder()
.ids(StdFunctions.format(FormatArgs.builder()
.input("%s:%s")
.args(
defaultSharedResource.resourceId(),
defaultSharedResource.resourceType())
.build()).result())
.build());
ctx.export("firstResourceManagerSharedResourceId", ids.resources()[0].id());
final var resourceShareId = ResourcemanagerFunctions.getSharedResources(GetSharedResourcesArgs.builder()
.resourceShareId(defaultSharedResource.resourceShareId())
.build());
ctx.export("secondResourceManagerSharedResourceId", resourceShareId.applyValue(_resourceShareId -> _resourceShareId.resources()[0].id()));
}
}
configuration:
name:
type: string
default: tf-example
resources:
defaultResourceShare:
type: alicloud:resourcemanager:ResourceShare
name: default
properties:
resourceShareName: ${name}
defaultSharedResource:
type: alicloud:resourcemanager:SharedResource
name: default
properties:
resourceShareId: ${defaultResourceShare.id}
resourceId: ${defaultGetSwitches.ids[0]}
resourceType: VSwitch
variables:
default:
fn::invoke:
function: alicloud:getZones
arguments:
availableResourceCreation: VSwitch
defaultGetNetworks:
fn::invoke:
function: alicloud:vpc:getNetworks
arguments:
nameRegex: ^default-NODELETING$
defaultGetSwitches:
fn::invoke:
function: alicloud:vpc:getSwitches
arguments:
vpcId: ${defaultGetNetworks.ids[0]}
zoneId: ${default.ids[0]}
ids:
fn::invoke:
function: alicloud:resourcemanager:getSharedResources
arguments:
ids:
- fn::invoke:
function: std:format
arguments:
input: '%s:%s'
args:
- ${defaultSharedResource.resourceId}
- ${defaultSharedResource.resourceType}
return: result
resourceShareId:
fn::invoke:
function: alicloud:resourcemanager:getSharedResources
arguments:
resourceShareId: ${defaultSharedResource.resourceShareId}
outputs:
firstResourceManagerSharedResourceId: ${ids.resources[0].id}
secondResourceManagerSharedResourceId: ${resourceShareId.resources[0].id}
Using getSharedResources
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 getSharedResources(args: GetSharedResourcesArgs, opts?: InvokeOptions): Promise<GetSharedResourcesResult>
function getSharedResourcesOutput(args: GetSharedResourcesOutputArgs, opts?: InvokeOptions): Output<GetSharedResourcesResult>def get_shared_resources(ids: Optional[Sequence[str]] = None,
output_file: Optional[str] = None,
resource_share_id: Optional[str] = None,
status: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSharedResourcesResult
def get_shared_resources_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[GetSharedResourcesResult]func GetSharedResources(ctx *Context, args *GetSharedResourcesArgs, opts ...InvokeOption) (*GetSharedResourcesResult, error)
func GetSharedResourcesOutput(ctx *Context, args *GetSharedResourcesOutputArgs, opts ...InvokeOption) GetSharedResourcesResultOutput> Note: This function is named GetSharedResources in the Go SDK.
public static class GetSharedResources
{
public static Task<GetSharedResourcesResult> InvokeAsync(GetSharedResourcesArgs args, InvokeOptions? opts = null)
public static Output<GetSharedResourcesResult> Invoke(GetSharedResourcesInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetSharedResourcesResult> getSharedResources(GetSharedResourcesArgs args, InvokeOptions options)
public static Output<GetSharedResourcesResult> getSharedResources(GetSharedResourcesArgs args, InvokeOptions options)
fn::invoke:
function: alicloud:resourcemanager/getSharedResources:getSharedResources
arguments:
# arguments dictionaryThe following arguments are supported:
- Ids List<string>
- A list of shared resource 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,DisassociatingandFailed.
- Ids []string
- A list of shared resource 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,DisassociatingandFailed.
- ids List<String>
- A list of shared resource 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,DisassociatingandFailed.
- ids string[]
- A list of shared resource 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,DisassociatingandFailed.
- ids Sequence[str]
- A list of shared resource 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,DisassociatingandFailed.
- ids List<String>
- A list of shared resource 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,DisassociatingandFailed.
getSharedResources Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- Resources
List<Pulumi.
Ali Cloud. Resource Manager. Outputs. Get Shared Resources Resource> - A list of Resource Manager Shared Resources. Each element contains the following attributes:
- Output
File string - string
- The resource share ID of resource manager.
- Status string
- The status of shared resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- Resources
[]Get
Shared Resources Resource - A list of Resource Manager Shared Resources. Each element contains the following attributes:
- Output
File string - string
- The resource share ID of resource manager.
- Status string
- The status of shared resource.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- resources
List<Get
Shared Resources Resource> - A list of Resource Manager Shared Resources. Each element contains the following attributes:
- output
File String - String
- The resource share ID of resource manager.
- status String
- The status of shared resource.
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- resources
Get
Shared Resources Resource[] - A list of Resource Manager Shared Resources. Each element contains the following attributes:
- output
File string - string
- The resource share ID of resource manager.
- status string
- The status of shared resource.
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- resources
Sequence[Get
Shared Resources Resource] - A list of Resource Manager Shared Resources. Each element contains the following attributes:
- output_
file str - str
- The resource share ID of resource manager.
- status str
- The status of shared resource.
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- resources List<Property Map>
- A list of Resource Manager Shared Resources. Each element contains the following attributes:
- output
File String - String
- The resource share ID of resource manager.
- status String
- The status of shared resource.
Supporting Types
GetSharedResourcesResource
- Id string
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - Resource
Id string - The ID of the shared resource.
- string
- The resource share ID of resource manager.
- Resource
Type string - The type of shared resource.
- Status string
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
- Id string
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - Resource
Id string - The ID of the shared resource.
- string
- The resource share ID of resource manager.
- Resource
Type string - The type of shared resource.
- Status string
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
- id String
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - resource
Id String - The ID of the shared resource.
- String
- The resource share ID of resource manager.
- resource
Type String - The type of shared resource.
- status String
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
- id string
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - resource
Id string - The ID of the shared resource.
- string
- The resource share ID of resource manager.
- resource
Type string - The type of shared resource.
- status string
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
- id str
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - resource_
id str - The ID of the shared resource.
- str
- The resource share ID of resource manager.
- resource_
type str - The type of shared resource.
- status str
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
- id String
- The ID of the Shared Resource. It formats as
<resource_id>:<resource_type>. - resource
Id String - The ID of the shared resource.
- String
- The resource share ID of resource manager.
- resource
Type String - The type of shared resource.
- status String
- The status of share resource. Valid values:
Associated,Associating,Disassociated,DisassociatingandFailed.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.
