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

alicloud.mhub.getProducts

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides the Mhub Products of the current Alibaba Cloud user.

NOTE: Available in v1.138.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") || "example_value";
const _default = new alicloud.mhub.Product("default", {productName: name});
const ids = alicloud.mhub.getProducts({});
export const mhubProductId1 = ids.then(ids => ids.products?.[0]?.id);
const nameRegex = alicloud.mhub.getProducts({
    nameRegex: "^my-Product",
});
export const mhubProductId2 = nameRegex.then(nameRegex => nameRegex.products?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "example_value"
default = alicloud.mhub.Product("default", product_name=name)
ids = alicloud.mhub.get_products()
pulumi.export("mhubProductId1", ids.products[0].id)
name_regex = alicloud.mhub.get_products(name_regex="^my-Product")
pulumi.export("mhubProductId2", name_regex.products[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mhub"
	"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 := "example_value"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		_, err := mhub.NewProduct(ctx, "default", &mhub.ProductArgs{
			ProductName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		ids, err := mhub.GetProducts(ctx, &mhub.GetProductsArgs{}, nil)
		if err != nil {
			return err
		}
		ctx.Export("mhubProductId1", ids.Products[0].Id)
		nameRegex, err := mhub.GetProducts(ctx, &mhub.GetProductsArgs{
			NameRegex: pulumi.StringRef("^my-Product"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("mhubProductId2", nameRegex.Products[0].Id)
		return nil
	})
}
Copy
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") ?? "example_value";
    var @default = new AliCloud.Mhub.Product("default", new()
    {
        ProductName = name,
    });

    var ids = AliCloud.Mhub.GetProducts.Invoke();

    var nameRegex = AliCloud.Mhub.GetProducts.Invoke(new()
    {
        NameRegex = "^my-Product",
    });

    return new Dictionary<string, object?>
    {
        ["mhubProductId1"] = ids.Apply(getProductsResult => getProductsResult.Products[0]?.Id),
        ["mhubProductId2"] = nameRegex.Apply(getProductsResult => getProductsResult.Products[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.mhub.Product;
import com.pulumi.alicloud.mhub.ProductArgs;
import com.pulumi.alicloud.mhub.MhubFunctions;
import com.pulumi.alicloud.mhub.inputs.GetProductsArgs;
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("example_value");
        var default_ = new Product("default", ProductArgs.builder()
            .productName(name)
            .build());

        final var ids = MhubFunctions.getProducts();

        ctx.export("mhubProductId1", ids.applyValue(getProductsResult -> getProductsResult.products()[0].id()));
        final var nameRegex = MhubFunctions.getProducts(GetProductsArgs.builder()
            .nameRegex("^my-Product")
            .build());

        ctx.export("mhubProductId2", nameRegex.applyValue(getProductsResult -> getProductsResult.products()[0].id()));
    }
}
Copy
configuration:
  name:
    type: string
    default: example_value
resources:
  default:
    type: alicloud:mhub:Product
    properties:
      productName: ${name}
variables:
  ids:
    fn::invoke:
      function: alicloud:mhub:getProducts
      arguments: {}
  nameRegex:
    fn::invoke:
      function: alicloud:mhub:getProducts
      arguments:
        nameRegex: ^my-Product
outputs:
  mhubProductId1: ${ids.products[0].id}
  mhubProductId2: ${nameRegex.products[0].id}
Copy

Using getProducts

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 getProducts(args: GetProductsArgs, opts?: InvokeOptions): Promise<GetProductsResult>
function getProductsOutput(args: GetProductsOutputArgs, opts?: InvokeOptions): Output<GetProductsResult>
Copy
def get_products(ids: Optional[Sequence[str]] = None,
                 name_regex: Optional[str] = None,
                 output_file: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetProductsResult
def get_products_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                 name_regex: Optional[pulumi.Input[str]] = None,
                 output_file: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetProductsResult]
Copy
func GetProducts(ctx *Context, args *GetProductsArgs, opts ...InvokeOption) (*GetProductsResult, error)
func GetProductsOutput(ctx *Context, args *GetProductsOutputArgs, opts ...InvokeOption) GetProductsResultOutput
Copy

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

public static class GetProducts 
{
    public static Task<GetProductsResult> InvokeAsync(GetProductsArgs args, InvokeOptions? opts = null)
    public static Output<GetProductsResult> Invoke(GetProductsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetProductsResult> getProducts(GetProductsArgs args, InvokeOptions options)
public static Output<GetProductsResult> getProducts(GetProductsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:mhub/getProducts:getProducts
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Ids Changes to this property will trigger replacement. List<string>
A list of Product IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Product name.
OutputFile string
File name where to save data source results (after running pulumi preview).
Ids Changes to this property will trigger replacement. []string
A list of Product IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Product name.
OutputFile string
File name where to save data source results (after running pulumi preview).
ids Changes to this property will trigger replacement. List<String>
A list of Product IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by Product name.
outputFile String
File name where to save data source results (after running pulumi preview).
ids Changes to this property will trigger replacement. string[]
A list of Product IDs.
nameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Product name.
outputFile string
File name where to save data source results (after running pulumi preview).
ids Changes to this property will trigger replacement. Sequence[str]
A list of Product IDs.
name_regex Changes to this property will trigger replacement. str
A regex string to filter results by Product name.
output_file str
File name where to save data source results (after running pulumi preview).
ids Changes to this property will trigger replacement. List<String>
A list of Product IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by Product name.
outputFile String
File name where to save data source results (after running pulumi preview).

getProducts Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
Names List<string>
Products List<Pulumi.AliCloud.Mhub.Outputs.GetProductsProduct>
NameRegex string
OutputFile string
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
Names []string
Products []GetProductsProduct
NameRegex string
OutputFile string
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
products List<GetProductsProduct>
nameRegex String
outputFile String
id string
The provider-assigned unique ID for this managed resource.
ids string[]
names string[]
products GetProductsProduct[]
nameRegex string
outputFile string
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
names Sequence[str]
products Sequence[GetProductsProduct]
name_regex str
output_file str
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
products List<Property Map>
nameRegex String
outputFile String

Supporting Types

GetProductsProduct

Id This property is required. string
The ID of the Product.
ProductId This property is required. string
The ID of the Product.
ProductName This property is required. string
The name of the Product.
Id This property is required. string
The ID of the Product.
ProductId This property is required. string
The ID of the Product.
ProductName This property is required. string
The name of the Product.
id This property is required. String
The ID of the Product.
productId This property is required. String
The ID of the Product.
productName This property is required. String
The name of the Product.
id This property is required. string
The ID of the Product.
productId This property is required. string
The ID of the Product.
productName This property is required. string
The name of the Product.
id This property is required. str
The ID of the Product.
product_id This property is required. str
The ID of the Product.
product_name This property is required. str
The name of the Product.
id This property is required. String
The ID of the Product.
productId This property is required. String
The ID of the Product.
productName This property is required. String
The name of the Product.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi