1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ots
  5. getInstanceAttachments
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.ots.getInstanceAttachments

Explore with Pulumi AI

This data source provides the ots instance attachments of the current Alibaba Cloud user.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const attachmentsDs = alicloud.ots.getInstanceAttachments({
    instanceName: "sample-instance",
    nameRegex: "testvpc",
    outputFile: "attachments.txt",
});
export const firstOtsAttachmentId = attachmentsDs.then(attachmentsDs => attachmentsDs.attachments?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

attachments_ds = alicloud.ots.get_instance_attachments(instance_name="sample-instance",
    name_regex="testvpc",
    output_file="attachments.txt")
pulumi.export("firstOtsAttachmentId", attachments_ds.attachments[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ots"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		attachmentsDs, err := ots.GetInstanceAttachments(ctx, &ots.GetInstanceAttachmentsArgs{
			InstanceName: "sample-instance",
			NameRegex:    pulumi.StringRef("testvpc"),
			OutputFile:   pulumi.StringRef("attachments.txt"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("firstOtsAttachmentId", attachmentsDs.Attachments[0].Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var attachmentsDs = AliCloud.Ots.GetInstanceAttachments.Invoke(new()
    {
        InstanceName = "sample-instance",
        NameRegex = "testvpc",
        OutputFile = "attachments.txt",
    });

    return new Dictionary<string, object?>
    {
        ["firstOtsAttachmentId"] = attachmentsDs.Apply(getInstanceAttachmentsResult => getInstanceAttachmentsResult.Attachments[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ots.OtsFunctions;
import com.pulumi.alicloud.ots.inputs.GetInstanceAttachmentsArgs;
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 attachmentsDs = OtsFunctions.getInstanceAttachments(GetInstanceAttachmentsArgs.builder()
            .instanceName("sample-instance")
            .nameRegex("testvpc")
            .outputFile("attachments.txt")
            .build());

        ctx.export("firstOtsAttachmentId", attachmentsDs.applyValue(getInstanceAttachmentsResult -> getInstanceAttachmentsResult.attachments()[0].id()));
    }
}
Copy
variables:
  attachmentsDs:
    fn::invoke:
      function: alicloud:ots:getInstanceAttachments
      arguments:
        instanceName: sample-instance
        nameRegex: testvpc
        outputFile: attachments.txt
outputs:
  firstOtsAttachmentId: ${attachmentsDs.attachments[0].id}
Copy

Using getInstanceAttachments

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 getInstanceAttachments(args: GetInstanceAttachmentsArgs, opts?: InvokeOptions): Promise<GetInstanceAttachmentsResult>
function getInstanceAttachmentsOutput(args: GetInstanceAttachmentsOutputArgs, opts?: InvokeOptions): Output<GetInstanceAttachmentsResult>
Copy
def get_instance_attachments(instance_name: Optional[str] = None,
                             name_regex: Optional[str] = None,
                             output_file: Optional[str] = None,
                             opts: Optional[InvokeOptions] = None) -> GetInstanceAttachmentsResult
def get_instance_attachments_output(instance_name: Optional[pulumi.Input[str]] = None,
                             name_regex: Optional[pulumi.Input[str]] = None,
                             output_file: Optional[pulumi.Input[str]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetInstanceAttachmentsResult]
Copy
func GetInstanceAttachments(ctx *Context, args *GetInstanceAttachmentsArgs, opts ...InvokeOption) (*GetInstanceAttachmentsResult, error)
func GetInstanceAttachmentsOutput(ctx *Context, args *GetInstanceAttachmentsOutputArgs, opts ...InvokeOption) GetInstanceAttachmentsResultOutput
Copy

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

public static class GetInstanceAttachments 
{
    public static Task<GetInstanceAttachmentsResult> InvokeAsync(GetInstanceAttachmentsArgs args, InvokeOptions? opts = null)
    public static Output<GetInstanceAttachmentsResult> Invoke(GetInstanceAttachmentsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetInstanceAttachmentsResult> getInstanceAttachments(GetInstanceAttachmentsArgs args, InvokeOptions options)
public static Output<GetInstanceAttachmentsResult> getInstanceAttachments(GetInstanceAttachmentsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:ots/getInstanceAttachments:getInstanceAttachments
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

InstanceName This property is required. string
The name of OTS instance.
NameRegex string
A regex string to filter results by vpc name.
OutputFile string
File name where to save data source results (after running pulumi preview).
InstanceName This property is required. string
The name of OTS instance.
NameRegex string
A regex string to filter results by vpc name.
OutputFile string
File name where to save data source results (after running pulumi preview).
instanceName This property is required. String
The name of OTS instance.
nameRegex String
A regex string to filter results by vpc name.
outputFile String
File name where to save data source results (after running pulumi preview).
instanceName This property is required. string
The name of OTS instance.
nameRegex string
A regex string to filter results by vpc name.
outputFile string
File name where to save data source results (after running pulumi preview).
instance_name This property is required. str
The name of OTS instance.
name_regex str
A regex string to filter results by vpc name.
output_file str
File name where to save data source results (after running pulumi preview).
instanceName This property is required. String
The name of OTS instance.
nameRegex String
A regex string to filter results by vpc name.
outputFile String
File name where to save data source results (after running pulumi preview).

getInstanceAttachments Result

The following output properties are available:

Attachments List<Pulumi.AliCloud.Ots.Outputs.GetInstanceAttachmentsAttachment>
A list of instance attachments. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
InstanceName string
The instance name.
Names List<string>
A list of vpc names.
VpcIds List<string>
A list of vpc ids.
NameRegex string
OutputFile string
Attachments []GetInstanceAttachmentsAttachment
A list of instance attachments. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
InstanceName string
The instance name.
Names []string
A list of vpc names.
VpcIds []string
A list of vpc ids.
NameRegex string
OutputFile string
attachments List<GetInstanceAttachmentsAttachment>
A list of instance attachments. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
instanceName String
The instance name.
names List<String>
A list of vpc names.
vpcIds List<String>
A list of vpc ids.
nameRegex String
outputFile String
attachments GetInstanceAttachmentsAttachment[]
A list of instance attachments. Each element contains the following attributes:
id string
The provider-assigned unique ID for this managed resource.
instanceName string
The instance name.
names string[]
A list of vpc names.
vpcIds string[]
A list of vpc ids.
nameRegex string
outputFile string
attachments Sequence[GetInstanceAttachmentsAttachment]
A list of instance attachments. Each element contains the following attributes:
id str
The provider-assigned unique ID for this managed resource.
instance_name str
The instance name.
names Sequence[str]
A list of vpc names.
vpc_ids Sequence[str]
A list of vpc ids.
name_regex str
output_file str
attachments List<Property Map>
A list of instance attachments. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
instanceName String
The instance name.
names List<String>
A list of vpc names.
vpcIds List<String>
A list of vpc ids.
nameRegex String
outputFile String

Supporting Types

GetInstanceAttachmentsAttachment

Domain This property is required. string
The domain of the instance attachment.
Endpoint This property is required. string
The access endpoint of the instance attachment.
Id This property is required. string
The resource ID, the value is same as "instance_name".
InstanceName This property is required. string
The name of OTS instance.
Region This property is required. string
The region of the instance attachment.
VpcId This property is required. string
The ID of attaching VPC to instance.
VpcName This property is required. string
The name of attaching VPC to instance.
Domain This property is required. string
The domain of the instance attachment.
Endpoint This property is required. string
The access endpoint of the instance attachment.
Id This property is required. string
The resource ID, the value is same as "instance_name".
InstanceName This property is required. string
The name of OTS instance.
Region This property is required. string
The region of the instance attachment.
VpcId This property is required. string
The ID of attaching VPC to instance.
VpcName This property is required. string
The name of attaching VPC to instance.
domain This property is required. String
The domain of the instance attachment.
endpoint This property is required. String
The access endpoint of the instance attachment.
id This property is required. String
The resource ID, the value is same as "instance_name".
instanceName This property is required. String
The name of OTS instance.
region This property is required. String
The region of the instance attachment.
vpcId This property is required. String
The ID of attaching VPC to instance.
vpcName This property is required. String
The name of attaching VPC to instance.
domain This property is required. string
The domain of the instance attachment.
endpoint This property is required. string
The access endpoint of the instance attachment.
id This property is required. string
The resource ID, the value is same as "instance_name".
instanceName This property is required. string
The name of OTS instance.
region This property is required. string
The region of the instance attachment.
vpcId This property is required. string
The ID of attaching VPC to instance.
vpcName This property is required. string
The name of attaching VPC to instance.
domain This property is required. str
The domain of the instance attachment.
endpoint This property is required. str
The access endpoint of the instance attachment.
id This property is required. str
The resource ID, the value is same as "instance_name".
instance_name This property is required. str
The name of OTS instance.
region This property is required. str
The region of the instance attachment.
vpc_id This property is required. str
The ID of attaching VPC to instance.
vpc_name This property is required. str
The name of attaching VPC to instance.
domain This property is required. String
The domain of the instance attachment.
endpoint This property is required. String
The access endpoint of the instance attachment.
id This property is required. String
The resource ID, the value is same as "instance_name".
instanceName This property is required. String
The name of OTS instance.
region This property is required. String
The region of the instance attachment.
vpcId This property is required. String
The ID of attaching VPC to instance.
vpcName This property is required. String
The name of attaching VPC to instance.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.