Provides a Resource Manager Shared Resource resource.
For information about Resource Manager Shared Resource and how to use it, see What is Shared Resource.
NOTE: Available since v1.111.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = alicloud.getZones({
availableResourceCreation: "VSwitch",
});
const defaultInteger = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: `${name}-${defaultInteger.result}`,
cidrBlock: "192.168.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
zoneId: _default.then(_default => _default.zones?.[0]?.id),
cidrBlock: "192.168.0.0/16",
vpcId: defaultNetwork.id,
vswitchName: `${name}-${defaultInteger.result}`,
});
const defaultResourceShare = new alicloud.resourcemanager.ResourceShare("default", {resourceShareName: `${name}-${defaultInteger.result}`});
const defaultSharedResource = new alicloud.resourcemanager.SharedResource("default", {
resourceShareId: defaultResourceShare.id,
resourceId: defaultSwitch.id,
resourceType: "VSwitch",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = alicloud.get_zones(available_resource_creation="VSwitch")
default_integer = random.index.Integer("default",
min=10000,
max=99999)
default_network = alicloud.vpc.Network("default",
vpc_name=f"{name}-{default_integer['result']}",
cidr_block="192.168.0.0/16")
default_switch = alicloud.vpc.Switch("default",
zone_id=default.zones[0].id,
cidr_block="192.168.0.0/16",
vpc_id=default_network.id,
vswitch_name=f"{name}-{default_integer['result']}")
default_resource_share = alicloud.resourcemanager.ResourceShare("default", resource_share_name=f"{name}-{default_integer['result']}")
default_shared_resource = alicloud.resourcemanager.SharedResource("default",
resource_share_id=default_resource_share.id,
resource_id=default_switch.id,
resource_type="VSwitch")
package main
import (
"fmt"
"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-random/sdk/v4/go/random"
"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 := "terraform-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
}
defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.Sprintf("%v-%v", name, defaultInteger.Result),
CidrBlock: pulumi.String("192.168.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
ZoneId: pulumi.String(_default.Zones[0].Id),
CidrBlock: pulumi.String("192.168.0.0/16"),
VpcId: defaultNetwork.ID(),
VswitchName: pulumi.Sprintf("%v-%v", name, defaultInteger.Result),
})
if err != nil {
return err
}
defaultResourceShare, err := resourcemanager.NewResourceShare(ctx, "default", &resourcemanager.ResourceShareArgs{
ResourceShareName: pulumi.Sprintf("%v-%v", name, defaultInteger.Result),
})
if err != nil {
return err
}
_, err = resourcemanager.NewSharedResource(ctx, "default", &resourcemanager.SharedResourceArgs{
ResourceShareId: defaultResourceShare.ID(),
ResourceId: defaultSwitch.ID(),
ResourceType: pulumi.String("VSwitch"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableResourceCreation = "VSwitch",
});
var defaultInteger = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = $"{name}-{defaultInteger.Result}",
CidrBlock = "192.168.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
CidrBlock = "192.168.0.0/16",
VpcId = defaultNetwork.Id,
VswitchName = $"{name}-{defaultInteger.Result}",
});
var defaultResourceShare = new AliCloud.ResourceManager.ResourceShare("default", new()
{
ResourceShareName = $"{name}-{defaultInteger.Result}",
});
var defaultSharedResource = new AliCloud.ResourceManager.SharedResource("default", new()
{
ResourceShareId = defaultResourceShare.Id,
ResourceId = defaultSwitch.Id,
ResourceType = "VSwitch",
});
});
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.random.Integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
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 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("terraform-example");
final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(String.format("%s-%s", name,defaultInteger.result()))
.cidrBlock("192.168.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.zoneId(default_.zones()[0].id())
.cidrBlock("192.168.0.0/16")
.vpcId(defaultNetwork.id())
.vswitchName(String.format("%s-%s", name,defaultInteger.result()))
.build());
var defaultResourceShare = new ResourceShare("defaultResourceShare", ResourceShareArgs.builder()
.resourceShareName(String.format("%s-%s", name,defaultInteger.result()))
.build());
var defaultSharedResource = new SharedResource("defaultSharedResource", SharedResourceArgs.builder()
.resourceShareId(defaultResourceShare.id())
.resourceId(defaultSwitch.id())
.resourceType("VSwitch")
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
defaultInteger:
type: random:Integer
name: default
properties:
min: 10000
max: 99999
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
vpcName: ${name}-${defaultInteger.result}
cidrBlock: 192.168.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
zoneId: ${default.zones[0].id}
cidrBlock: 192.168.0.0/16
vpcId: ${defaultNetwork.id}
vswitchName: ${name}-${defaultInteger.result}
defaultResourceShare:
type: alicloud:resourcemanager:ResourceShare
name: default
properties:
resourceShareName: ${name}-${defaultInteger.result}
defaultSharedResource:
type: alicloud:resourcemanager:SharedResource
name: default
properties:
resourceShareId: ${defaultResourceShare.id}
resourceId: ${defaultSwitch.id}
resourceType: VSwitch
variables:
default:
fn::invoke:
function: alicloud:getZones
arguments:
availableResourceCreation: VSwitch
📚 Need more examples? VIEW MORE EXAMPLES
Create SharedResource Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SharedResource(name: string, args: SharedResourceArgs, opts?: CustomResourceOptions);@overload
def SharedResource(resource_name: str,
args: SharedResourceArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SharedResource(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_share_id: Optional[str] = None,
permission_name: Optional[str] = None,
resource_arn: Optional[str] = None,
resource_id: Optional[str] = None,
resource_type: Optional[str] = None)func NewSharedResource(ctx *Context, name string, args SharedResourceArgs, opts ...ResourceOption) (*SharedResource, error)public SharedResource(string name, SharedResourceArgs args, CustomResourceOptions? opts = null)
public SharedResource(String name, SharedResourceArgs args)
public SharedResource(String name, SharedResourceArgs args, CustomResourceOptions options)
type: alicloud:resourcemanager:SharedResource
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SharedResourceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SharedResourceArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SharedResourceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SharedResourceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SharedResourceArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var sharedResourceResource = new AliCloud.ResourceManager.SharedResource("sharedResourceResource", new()
{
ResourceShareId = "string",
PermissionName = "string",
ResourceArn = "string",
ResourceId = "string",
ResourceType = "string",
});
example, err := resourcemanager.NewSharedResource(ctx, "sharedResourceResource", &resourcemanager.SharedResourceArgs{
ResourceShareId: pulumi.String("string"),
PermissionName: pulumi.String("string"),
ResourceArn: pulumi.String("string"),
ResourceId: pulumi.String("string"),
ResourceType: pulumi.String("string"),
})
var sharedResourceResource = new SharedResource("sharedResourceResource", SharedResourceArgs.builder()
.resourceShareId("string")
.permissionName("string")
.resourceArn("string")
.resourceId("string")
.resourceType("string")
.build());
shared_resource_resource = alicloud.resourcemanager.SharedResource("sharedResourceResource",
resource_share_id="string",
permission_name="string",
resource_arn="string",
resource_id="string",
resource_type="string")
const sharedResourceResource = new alicloud.resourcemanager.SharedResource("sharedResourceResource", {
resourceShareId: "string",
permissionName: "string",
resourceArn: "string",
resourceId: "string",
resourceType: "string",
});
type: alicloud:resourcemanager:SharedResource
properties:
permissionName: string
resourceArn: string
resourceId: string
resourceShareId: string
resourceType: string
SharedResource Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The SharedResource resource accepts the following input properties:
- string
- The ID of the resource share.
- Permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- Resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- Resource
Id string - The ID of the shared resource.
- Resource
Type string - The type of the shared resource.
- string
- The ID of the resource share.
- Permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- Resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- Resource
Id string - The ID of the shared resource.
- Resource
Type string - The type of the shared resource.
- String
- The ID of the resource share.
- permission
Name String The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn String Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id String - The ID of the shared resource.
- resource
Type String - The type of the shared resource.
- string
- The ID of the resource share.
- permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id string - The ID of the shared resource.
- resource
Type string - The type of the shared resource.
- str
- The ID of the resource share.
- permission_
name str The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource_
arn str Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource_
id str - The ID of the shared resource.
- resource_
type str - The type of the shared resource.
- String
- The ID of the resource share.
- permission
Name String The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn String Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id String - The ID of the shared resource.
- resource
Type String - The type of the shared resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the SharedResource resource produces the following output properties:
- Create
Time string - The time when the shared resource was associated with the resource share.
- Id string
- The provider-assigned unique ID for this managed resource.
- Status string
- The association status.
- Create
Time string - The time when the shared resource was associated with the resource share.
- Id string
- The provider-assigned unique ID for this managed resource.
- Status string
- The association status.
- create
Time String - The time when the shared resource was associated with the resource share.
- id String
- The provider-assigned unique ID for this managed resource.
- status String
- The association status.
- create
Time string - The time when the shared resource was associated with the resource share.
- id string
- The provider-assigned unique ID for this managed resource.
- status string
- The association status.
- create_
time str - The time when the shared resource was associated with the resource share.
- id str
- The provider-assigned unique ID for this managed resource.
- status str
- The association status.
- create
Time String - The time when the shared resource was associated with the resource share.
- id String
- The provider-assigned unique ID for this managed resource.
- status String
- The association status.
Look up Existing SharedResource Resource
Get an existing SharedResource resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SharedResourceState, opts?: CustomResourceOptions): SharedResource@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
create_time: Optional[str] = None,
permission_name: Optional[str] = None,
resource_arn: Optional[str] = None,
resource_id: Optional[str] = None,
resource_share_id: Optional[str] = None,
resource_type: Optional[str] = None,
status: Optional[str] = None) -> SharedResourcefunc GetSharedResource(ctx *Context, name string, id IDInput, state *SharedResourceState, opts ...ResourceOption) (*SharedResource, error)public static SharedResource Get(string name, Input<string> id, SharedResourceState? state, CustomResourceOptions? opts = null)public static SharedResource get(String name, Output<String> id, SharedResourceState state, CustomResourceOptions options)resources: _: type: alicloud:resourcemanager:SharedResource get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Create
Time string - The time when the shared resource was associated with the resource share.
- Permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- Resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- Resource
Id string - The ID of the shared resource.
- string
- The ID of the resource share.
- Resource
Type string - The type of the shared resource.
- Status string
- The association status.
- Create
Time string - The time when the shared resource was associated with the resource share.
- Permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- Resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- Resource
Id string - The ID of the shared resource.
- string
- The ID of the resource share.
- Resource
Type string - The type of the shared resource.
- Status string
- The association status.
- create
Time String - The time when the shared resource was associated with the resource share.
- permission
Name String The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn String Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id String - The ID of the shared resource.
- String
- The ID of the resource share.
- resource
Type String - The type of the shared resource.
- status String
- The association status.
- create
Time string - The time when the shared resource was associated with the resource share.
- permission
Name string The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn string Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id string - The ID of the shared resource.
- string
- The ID of the resource share.
- resource
Type string - The type of the shared resource.
- status string
- The association status.
- create_
time str - The time when the shared resource was associated with the resource share.
- permission_
name str The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource_
arn str Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource_
id str - The ID of the shared resource.
- str
- The ID of the resource share.
- resource_
type str - The type of the shared resource.
- status str
- The association status.
- create
Time String - The time when the shared resource was associated with the resource share.
- permission
Name String The name of a permission. If you do not configure this parameter, the system automatically associates the default permission for the specified resource type with the resource share.
NOTE: The parameter is immutable after resource creation. It only applies during resource creation and has no effect when modified post-creation.
- resource
Arn String Associated resource ARN.
NOTE: This parameter is not available when the association type 'AssociationType' is the resource consumer 'Target'.
- resource
Id String - The ID of the shared resource.
- String
- The ID of the resource share.
- resource
Type String - The type of the shared resource.
- status String
- The association status.
Import
Resource Manager Shared Resource can be imported using the id, e.g.
$ pulumi import alicloud:resourcemanager/sharedResource:SharedResource example <resource_share_id>:<resource_id>:<resource_type>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloudTerraform Provider.
