Alibaba Cloud

Pulumi Official
Package maintained by Pulumi
v3.28.0 published on Tuesday, Aug 16, 2022 by Pulumi

getProducts

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

NOTE: Available in v1.138.0+.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var name = config.Get("name") ?? "example_value";
        var @default = new AliCloud.Mhub.Product("default", new AliCloud.Mhub.ProductArgs
        {
            ProductName = name,
        });
        var ids = Output.Create(AliCloud.Mhub.GetProducts.InvokeAsync());
        this.MhubProductId1 = ids.Apply(ids => ids.Products?[0]?.Id);
        var nameRegex = Output.Create(AliCloud.Mhub.GetProducts.InvokeAsync(new AliCloud.Mhub.GetProductsArgs
        {
            NameRegex = "^my-Product",
        }));
        this.MhubProductId2 = nameRegex.Apply(nameRegex => nameRegex.Products?[0]?.Id);
    }

    [Output("mhubProductId1")]
    public Output<string> MhubProductId1 { get; set; }
    [Output("mhubProductId2")]
    public Output<string> MhubProductId2 { get; set; }
}
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, nil, 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
	})
}
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.marketplace.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()));
    }
}
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)
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);
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}

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>
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]
func GetProducts(ctx *Context, args *GetProductsArgs, opts ...InvokeOption) (*GetProductsResult, error)
func GetProductsOutput(ctx *Context, args *GetProductsOutputArgs, opts ...InvokeOption) GetProductsResultOutput

> 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)
}
public static CompletableFuture<GetProductsResult> getProducts(GetProductsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: alicloud:mhub/getProducts:getProducts
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Ids List<string>

A list of Product IDs.

NameRegex string

A regex string to filter results by Product name.

OutputFile string
Ids []string

A list of Product IDs.

NameRegex string

A regex string to filter results by Product name.

OutputFile string
ids List<String>

A list of Product IDs.

nameRegex String

A regex string to filter results by Product name.

outputFile String
ids string[]

A list of Product IDs.

nameRegex string

A regex string to filter results by Product name.

outputFile string
ids Sequence[str]

A list of Product IDs.

name_regex str

A regex string to filter results by Product name.

output_file str
ids List<String>

A list of Product IDs.

nameRegex String

A regex string to filter results by Product name.

outputFile String

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 string

The ID of the Product.

ProductId string

The ID of the Product.

ProductName string

The name of the Product.

Id string

The ID of the Product.

ProductId string

The ID of the Product.

ProductName string

The name of the Product.

id String

The ID of the Product.

productId String

The ID of the Product.

productName String

The name of the Product.

id string

The ID of the Product.

productId string

The ID of the Product.

productName string

The name of the Product.

id str

The ID of the Product.

product_id str

The ID of the Product.

product_name str

The name of the Product.

id String

The ID of the Product.

productId String

The ID of the Product.

productName String

The name of the Product.

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.