alicloud.databasefilesystem.InstanceAttachment
Explore with Pulumi AI
Provides a DBFS Instance Attachment resource.
For information about DBFS Instance Attachment and how to use it.
NOTE: Available since v1.156.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 zoneId = "cn-hangzhou-i";
const example = alicloud.ecs.getInstanceTypes({
availabilityZone: zoneId,
instanceTypeFamily: "ecs.g7se",
});
const exampleGetImages = Promise.all([example, example.then(example => example.instanceTypes).length]).then(([example, length]) => alicloud.ecs.getImages({
instanceType: example.instanceTypes[length - 1].id,
nameRegex: "^aliyun_2_1903_x64_20G_alibase_20240628.vhd",
owners: "system",
}));
const default = alicloud.vpc.getNetworks({
nameRegex: "^default-NODELETING$",
});
const defaultGetSwitches = _default.then(_default => alicloud.vpc.getSwitches({
vpcId: _default.ids?.[0],
zoneId: zoneId,
}));
const exampleSecurityGroup = new alicloud.ecs.SecurityGroup("example", {
name: name,
vpcId: _default.then(_default => _default.ids?.[0]),
});
const defaultInstance = new alicloud.ecs.Instance("default", {
availabilityZone: zoneId,
instanceName: name,
imageId: exampleGetImages.then(exampleGetImages => exampleGetImages.images?.[0]?.id),
instanceType: Promise.all([example, example.then(example => example.instanceTypes).length]).then(([example, length]) => example.instanceTypes[length - 1].id),
securityGroups: [exampleSecurityGroup.id],
vswitchId: defaultGetSwitches.then(defaultGetSwitches => defaultGetSwitches.ids?.[0]),
systemDiskCategory: "cloud_essd",
});
const defaultInstance2 = new alicloud.databasefilesystem.Instance("default", {
category: "enterprise",
zoneId: defaultInstance.availabilityZone,
performanceLevel: "PL1",
fsName: name,
size: 100,
});
const exampleInstanceAttachment = new alicloud.databasefilesystem.InstanceAttachment("example", {
ecsId: defaultInstance.id,
instanceId: defaultInstance2.id,
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example"
zone_id = "cn-hangzhou-i"
example = alicloud.ecs.get_instance_types(availability_zone=zone_id,
instance_type_family="ecs.g7se")
example_get_images = alicloud.ecs.get_images(instance_type=example.instance_types[len(example.instance_types) - 1].id,
name_regex="^aliyun_2_1903_x64_20G_alibase_20240628.vhd",
owners="system")
default = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
default_get_switches = alicloud.vpc.get_switches(vpc_id=default.ids[0],
zone_id=zone_id)
example_security_group = alicloud.ecs.SecurityGroup("example",
name=name,
vpc_id=default.ids[0])
default_instance = alicloud.ecs.Instance("default",
availability_zone=zone_id,
instance_name=name,
image_id=example_get_images.images[0].id,
instance_type=example.instance_types[len(example.instance_types) - 1].id,
security_groups=[example_security_group.id],
vswitch_id=default_get_switches.ids[0],
system_disk_category="cloud_essd")
default_instance2 = alicloud.databasefilesystem.Instance("default",
category="enterprise",
zone_id=default_instance.availability_zone,
performance_level="PL1",
fs_name=name,
size=100)
example_instance_attachment = alicloud.databasefilesystem.InstanceAttachment("example",
ecs_id=default_instance.id,
instance_id=default_instance2.id)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/databasefilesystem"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"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
}
zoneId := "cn-hangzhou-i"
example, err := ecs.GetInstanceTypes(ctx, &ecs.GetInstanceTypesArgs{
AvailabilityZone: pulumi.StringRef(zoneId),
InstanceTypeFamily: pulumi.StringRef("ecs.g7se"),
}, nil)
if err != nil {
return err
}
exampleGetImages, err := ecs.GetImages(ctx, &ecs.GetImagesArgs{
InstanceType: pulumi.StringRef(example.InstanceTypes[len(example.InstanceTypes)-1].Id),
NameRegex: pulumi.StringRef("^aliyun_2_1903_x64_20G_alibase_20240628.vhd"),
Owners: pulumi.StringRef("system"),
}, nil)
if err != nil {
return err
}
_default, 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(_default.Ids[0]),
ZoneId: pulumi.StringRef(zoneId),
}, nil)
if err != nil {
return err
}
exampleSecurityGroup, err := ecs.NewSecurityGroup(ctx, "example", &ecs.SecurityGroupArgs{
Name: pulumi.String(name),
VpcId: pulumi.String(_default.Ids[0]),
})
if err != nil {
return err
}
defaultInstance, err := ecs.NewInstance(ctx, "default", &ecs.InstanceArgs{
AvailabilityZone: pulumi.String(zoneId),
InstanceName: pulumi.String(name),
ImageId: pulumi.String(exampleGetImages.Images[0].Id),
InstanceType: example.InstanceTypes[len(example.InstanceTypes)-1].Id,
SecurityGroups: pulumi.StringArray{
exampleSecurityGroup.ID(),
},
VswitchId: pulumi.String(defaultGetSwitches.Ids[0]),
SystemDiskCategory: pulumi.String("cloud_essd"),
})
if err != nil {
return err
}
defaultInstance2, err := databasefilesystem.NewInstance(ctx, "default", &databasefilesystem.InstanceArgs{
Category: pulumi.String("enterprise"),
ZoneId: defaultInstance.AvailabilityZone,
PerformanceLevel: pulumi.String("PL1"),
FsName: pulumi.String(name),
Size: pulumi.Int(100),
})
if err != nil {
return err
}
_, err = databasefilesystem.NewInstanceAttachment(ctx, "example", &databasefilesystem.InstanceAttachmentArgs{
EcsId: defaultInstance.ID(),
InstanceId: defaultInstance2.ID(),
})
if err != nil {
return err
}
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 zoneId = "cn-hangzhou-i";
var example = AliCloud.Ecs.GetInstanceTypes.Invoke(new()
{
AvailabilityZone = zoneId,
InstanceTypeFamily = "ecs.g7se",
});
var exampleGetImages = AliCloud.Ecs.GetImages.Invoke(new()
{
InstanceType = example.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes)[example.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes).Length - 1].Id,
NameRegex = "^aliyun_2_1903_x64_20G_alibase_20240628.vhd",
Owners = "system",
});
var @default = AliCloud.Vpc.GetNetworks.Invoke(new()
{
NameRegex = "^default-NODELETING$",
});
var defaultGetSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
{
VpcId = @default.Apply(getNetworksResult => getNetworksResult.Ids[0]),
ZoneId = zoneId,
});
var exampleSecurityGroup = new AliCloud.Ecs.SecurityGroup("example", new()
{
Name = name,
VpcId = @default.Apply(@default => @default.Apply(getNetworksResult => getNetworksResult.Ids[0])),
});
var defaultInstance = new AliCloud.Ecs.Instance("default", new()
{
AvailabilityZone = zoneId,
InstanceName = name,
ImageId = exampleGetImages.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
InstanceType = Output.Tuple(example, example.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes).Length).Apply(values =>
{
var example = values.Item1;
var length = values.Item2;
return example.Apply(getInstanceTypesResult => getInstanceTypesResult.InstanceTypes)[length - 1].Id;
}),
SecurityGroups = new[]
{
exampleSecurityGroup.Id,
},
VswitchId = defaultGetSwitches.Apply(getSwitchesResult => getSwitchesResult.Ids[0]),
SystemDiskCategory = "cloud_essd",
});
var defaultInstance2 = new AliCloud.DatabaseFilesystem.Instance("default", new()
{
Category = "enterprise",
ZoneId = defaultInstance.AvailabilityZone,
PerformanceLevel = "PL1",
FsName = name,
Size = 100,
});
var exampleInstanceAttachment = new AliCloud.DatabaseFilesystem.InstanceAttachment("example", new()
{
EcsId = defaultInstance.Id,
InstanceId = defaultInstance2.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.databasefilesystem.Instance;
import com.pulumi.alicloud.databasefilesystem.InstanceArgs;
import com.pulumi.alicloud.databasefilesystem.InstanceAttachment;
import com.pulumi.alicloud.databasefilesystem.InstanceAttachmentArgs;
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 zoneId = "cn-hangzhou-i";
final var example = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(zoneId)
.instanceTypeFamily("ecs.g7se")
.build());
final var exampleGetImages = EcsFunctions.getImages(GetImagesArgs.builder()
.instanceType(example.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes())[example.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()).length() - 1].id())
.nameRegex("^aliyun_2_1903_x64_20G_alibase_20240628.vhd")
.owners("system")
.build());
final var default = VpcFunctions.getNetworks(GetNetworksArgs.builder()
.nameRegex("^default-NODELETING$")
.build());
final var defaultGetSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
.vpcId(default_.ids()[0])
.zoneId(zoneId)
.build());
var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder()
.name(name)
.vpcId(default_.ids()[0])
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.availabilityZone(zoneId)
.instanceName(name)
.imageId(exampleGetImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.instanceType(example.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes())[example.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()).length() - 1].id())
.securityGroups(exampleSecurityGroup.id())
.vswitchId(defaultGetSwitches.applyValue(getSwitchesResult -> getSwitchesResult.ids()[0]))
.systemDiskCategory("cloud_essd")
.build());
var defaultInstance2 = new Instance("defaultInstance2", InstanceArgs.builder()
.category("enterprise")
.zoneId(defaultInstance.availabilityZone())
.performanceLevel("PL1")
.fsName(name)
.size(100)
.build());
var exampleInstanceAttachment = new InstanceAttachment("exampleInstanceAttachment", InstanceAttachmentArgs.builder()
.ecsId(defaultInstance.id())
.instanceId(defaultInstance2.id())
.build());
}
}
Coming soon!
Create InstanceAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new InstanceAttachment(name: string, args: InstanceAttachmentArgs, opts?: CustomResourceOptions);
@overload
def InstanceAttachment(resource_name: str,
args: InstanceAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def InstanceAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
ecs_id: Optional[str] = None,
instance_id: Optional[str] = None)
func NewInstanceAttachment(ctx *Context, name string, args InstanceAttachmentArgs, opts ...ResourceOption) (*InstanceAttachment, error)
public InstanceAttachment(string name, InstanceAttachmentArgs args, CustomResourceOptions? opts = null)
public InstanceAttachment(String name, InstanceAttachmentArgs args)
public InstanceAttachment(String name, InstanceAttachmentArgs args, CustomResourceOptions options)
type: alicloud:databasefilesystem:InstanceAttachment
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 InstanceAttachmentArgs
- 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 InstanceAttachmentArgs
- 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 InstanceAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstanceAttachmentArgs
- 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 alicloudInstanceAttachmentResource = new AliCloud.DatabaseFilesystem.InstanceAttachment("alicloudInstanceAttachmentResource", new()
{
EcsId = "string",
InstanceId = "string",
});
example, err := databasefilesystem.NewInstanceAttachment(ctx, "alicloudInstanceAttachmentResource", &databasefilesystem.InstanceAttachmentArgs{
EcsId: pulumi.String("string"),
InstanceId: pulumi.String("string"),
})
var alicloudInstanceAttachmentResource = new InstanceAttachment("alicloudInstanceAttachmentResource", InstanceAttachmentArgs.builder()
.ecsId("string")
.instanceId("string")
.build());
alicloud_instance_attachment_resource = alicloud.databasefilesystem.InstanceAttachment("alicloudInstanceAttachmentResource",
ecs_id="string",
instance_id="string")
const alicloudInstanceAttachmentResource = new alicloud.databasefilesystem.InstanceAttachment("alicloudInstanceAttachmentResource", {
ecsId: "string",
instanceId: "string",
});
type: alicloud:databasefilesystem:InstanceAttachment
properties:
ecsId: string
instanceId: string
InstanceAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The InstanceAttachment resource accepts the following input properties:
- Ecs
Id string - The ID of the ECS instance.
- Instance
Id string - The ID of the database file system.
- Ecs
Id string - The ID of the ECS instance.
- Instance
Id string - The ID of the database file system.
- ecs
Id String - The ID of the ECS instance.
- instance
Id String - The ID of the database file system.
- ecs
Id string - The ID of the ECS instance.
- instance
Id string - The ID of the database file system.
- ecs_
id str - The ID of the ECS instance.
- instance_
id str - The ID of the database file system.
- ecs
Id String - The ID of the ECS instance.
- instance
Id String - The ID of the database file system.
Outputs
All input properties are implicitly available as output properties. Additionally, the InstanceAttachment resource produces the following output properties:
Look up Existing InstanceAttachment Resource
Get an existing InstanceAttachment 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?: InstanceAttachmentState, opts?: CustomResourceOptions): InstanceAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
ecs_id: Optional[str] = None,
instance_id: Optional[str] = None,
status: Optional[str] = None) -> InstanceAttachment
func GetInstanceAttachment(ctx *Context, name string, id IDInput, state *InstanceAttachmentState, opts ...ResourceOption) (*InstanceAttachment, error)
public static InstanceAttachment Get(string name, Input<string> id, InstanceAttachmentState? state, CustomResourceOptions? opts = null)
public static InstanceAttachment get(String name, Output<String> id, InstanceAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- Ecs
Id string - The ID of the ECS instance.
- Instance
Id string - The ID of the database file system.
- Status string
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
- Ecs
Id string - The ID of the ECS instance.
- Instance
Id string - The ID of the database file system.
- Status string
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
- ecs
Id String - The ID of the ECS instance.
- instance
Id String - The ID of the database file system.
- status String
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
- ecs
Id string - The ID of the ECS instance.
- instance
Id string - The ID of the database file system.
- status string
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
- ecs_
id str - The ID of the ECS instance.
- instance_
id str - The ID of the database file system.
- status str
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
- ecs
Id String - The ID of the ECS instance.
- instance
Id String - The ID of the database file system.
- status String
- The status of Database file system. Valid values:
attached
,attaching
,unattached
,detaching
.
Import
DBFS Instance Attachment can be imported using the id, e.g.
$ pulumi import alicloud:databasefilesystem/instanceAttachment:InstanceAttachment example <instance_id>:<ecs_id>
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
alicloud
Terraform Provider.