1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. amqp
  5. getVirtualHosts
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

alicloud.amqp.getVirtualHosts

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

    This data source provides the Amqp Virtual Hosts of the current Alibaba Cloud user.

    NOTE: Available in v1.126.0+.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const ids = alicloud.amqp.getVirtualHosts({
        instanceId: "amqp-abc12345",
        ids: [
            "my-VirtualHost-1",
            "my-VirtualHost-2",
        ],
    });
    export const amqpVirtualHostId1 = ids.then(ids => ids.hosts?.[0]?.id);
    const nameRegex = alicloud.amqp.getVirtualHosts({
        instanceId: "amqp-abc12345",
        nameRegex: "^my-VirtualHost",
    });
    export const amqpVirtualHostId2 = nameRegex.then(nameRegex => nameRegex.hosts?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    ids = alicloud.amqp.get_virtual_hosts(instance_id="amqp-abc12345",
        ids=[
            "my-VirtualHost-1",
            "my-VirtualHost-2",
        ])
    pulumi.export("amqpVirtualHostId1", ids.hosts[0].id)
    name_regex = alicloud.amqp.get_virtual_hosts(instance_id="amqp-abc12345",
        name_regex="^my-VirtualHost")
    pulumi.export("amqpVirtualHostId2", name_regex.hosts[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/amqp"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		ids, err := amqp.GetVirtualHosts(ctx, &amqp.GetVirtualHostsArgs{
    			InstanceId: "amqp-abc12345",
    			Ids: []string{
    				"my-VirtualHost-1",
    				"my-VirtualHost-2",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("amqpVirtualHostId1", ids.Hosts[0].Id)
    		nameRegex, err := amqp.GetVirtualHosts(ctx, &amqp.GetVirtualHostsArgs{
    			InstanceId: "amqp-abc12345",
    			NameRegex:  pulumi.StringRef("^my-VirtualHost"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("amqpVirtualHostId2", nameRegex.Hosts[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var ids = AliCloud.Amqp.GetVirtualHosts.Invoke(new()
        {
            InstanceId = "amqp-abc12345",
            Ids = new[]
            {
                "my-VirtualHost-1",
                "my-VirtualHost-2",
            },
        });
    
        var nameRegex = AliCloud.Amqp.GetVirtualHosts.Invoke(new()
        {
            InstanceId = "amqp-abc12345",
            NameRegex = "^my-VirtualHost",
        });
    
        return new Dictionary<string, object?>
        {
            ["amqpVirtualHostId1"] = ids.Apply(getVirtualHostsResult => getVirtualHostsResult.Hosts[0]?.Id),
            ["amqpVirtualHostId2"] = nameRegex.Apply(getVirtualHostsResult => getVirtualHostsResult.Hosts[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.amqp.AmqpFunctions;
    import com.pulumi.alicloud.amqp.inputs.GetVirtualHostsArgs;
    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 ids = AmqpFunctions.getVirtualHosts(GetVirtualHostsArgs.builder()
                .instanceId("amqp-abc12345")
                .ids(            
                    "my-VirtualHost-1",
                    "my-VirtualHost-2")
                .build());
    
            ctx.export("amqpVirtualHostId1", ids.applyValue(getVirtualHostsResult -> getVirtualHostsResult.hosts()[0].id()));
            final var nameRegex = AmqpFunctions.getVirtualHosts(GetVirtualHostsArgs.builder()
                .instanceId("amqp-abc12345")
                .nameRegex("^my-VirtualHost")
                .build());
    
            ctx.export("amqpVirtualHostId2", nameRegex.applyValue(getVirtualHostsResult -> getVirtualHostsResult.hosts()[0].id()));
        }
    }
    
    variables:
      ids:
        fn::invoke:
          Function: alicloud:amqp:getVirtualHosts
          Arguments:
            instanceId: amqp-abc12345
            ids:
              - my-VirtualHost-1
              - my-VirtualHost-2
      nameRegex:
        fn::invoke:
          Function: alicloud:amqp:getVirtualHosts
          Arguments:
            instanceId: amqp-abc12345
            nameRegex: ^my-VirtualHost
    outputs:
      amqpVirtualHostId1: ${ids.hosts[0].id}
      amqpVirtualHostId2: ${nameRegex.hosts[0].id}
    

    Using getVirtualHosts

    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 getVirtualHosts(args: GetVirtualHostsArgs, opts?: InvokeOptions): Promise<GetVirtualHostsResult>
    function getVirtualHostsOutput(args: GetVirtualHostsOutputArgs, opts?: InvokeOptions): Output<GetVirtualHostsResult>
    def get_virtual_hosts(ids: Optional[Sequence[str]] = None,
                          instance_id: Optional[str] = None,
                          name_regex: Optional[str] = None,
                          output_file: Optional[str] = None,
                          opts: Optional[InvokeOptions] = None) -> GetVirtualHostsResult
    def get_virtual_hosts_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                          instance_id: Optional[pulumi.Input[str]] = None,
                          name_regex: Optional[pulumi.Input[str]] = None,
                          output_file: Optional[pulumi.Input[str]] = None,
                          opts: Optional[InvokeOptions] = None) -> Output[GetVirtualHostsResult]
    func GetVirtualHosts(ctx *Context, args *GetVirtualHostsArgs, opts ...InvokeOption) (*GetVirtualHostsResult, error)
    func GetVirtualHostsOutput(ctx *Context, args *GetVirtualHostsOutputArgs, opts ...InvokeOption) GetVirtualHostsResultOutput

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

    public static class GetVirtualHosts 
    {
        public static Task<GetVirtualHostsResult> InvokeAsync(GetVirtualHostsArgs args, InvokeOptions? opts = null)
        public static Output<GetVirtualHostsResult> Invoke(GetVirtualHostsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVirtualHostsResult> getVirtualHosts(GetVirtualHostsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:amqp/getVirtualHosts:getVirtualHosts
      arguments:
        # arguments dictionary

    The following arguments are supported:

    InstanceId string
    InstanceId.
    Ids List<string>
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    NameRegex string
    A regex string to filter results by Virtual Host name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    InstanceId string
    InstanceId.
    Ids []string
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    NameRegex string
    A regex string to filter results by Virtual Host name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    instanceId String
    InstanceId.
    ids List<String>
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    nameRegex String
    A regex string to filter results by Virtual Host name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    instanceId string
    InstanceId.
    ids string[]
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    nameRegex string
    A regex string to filter results by Virtual Host name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    instance_id str
    InstanceId.
    ids Sequence[str]
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    name_regex str
    A regex string to filter results by Virtual Host name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    instanceId String
    InstanceId.
    ids List<String>
    A list of Virtual Host IDs. Its element value is same as Virtual Host Name.
    nameRegex String
    A regex string to filter results by Virtual Host name.
    outputFile String
    File name where to save data source results (after running pulumi preview).

    getVirtualHosts Result

    The following output properties are available:

    Hosts List<Pulumi.AliCloud.Amqp.Outputs.GetVirtualHostsHost>
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    InstanceId string
    Names List<string>
    NameRegex string
    OutputFile string
    Hosts []GetVirtualHostsHost
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    InstanceId string
    Names []string
    NameRegex string
    OutputFile string
    hosts List<GetVirtualHostsHost>
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    instanceId String
    names List<String>
    nameRegex String
    outputFile String
    hosts GetVirtualHostsHost[]
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    instanceId string
    names string[]
    nameRegex string
    outputFile string
    hosts Sequence[GetVirtualHostsHost]
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    instance_id str
    names Sequence[str]
    name_regex str
    output_file str
    hosts List<Property Map>
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    instanceId String
    names List<String>
    nameRegex String
    outputFile String

    Supporting Types

    GetVirtualHostsHost

    Id string
    The ID of the Virtual Host.
    InstanceId string
    InstanceId.
    VirtualHostName string
    VirtualHostName.
    Id string
    The ID of the Virtual Host.
    InstanceId string
    InstanceId.
    VirtualHostName string
    VirtualHostName.
    id String
    The ID of the Virtual Host.
    instanceId String
    InstanceId.
    virtualHostName String
    VirtualHostName.
    id string
    The ID of the Virtual Host.
    instanceId string
    InstanceId.
    virtualHostName string
    VirtualHostName.
    id str
    The ID of the Virtual Host.
    instance_id str
    InstanceId.
    virtual_host_name str
    VirtualHostName.
    id String
    The ID of the Virtual Host.
    instanceId String
    InstanceId.
    virtualHostName String
    VirtualHostName.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi