get Key Pairs
This data source provides the Ens Key Pairs of the current Alibaba Cloud user.
NOTE: Available in v1.133.0+.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const nameRegex = alicloud.ens.getKeyPairs({
version: "example_value",
nameRegex: "^my-KeyPair",
});
export const ensKeyPairId1 = nameRegex.then(nameRegex => nameRegex.pairs?.[0]?.id);Content copied to clipboard
import pulumi
import pulumi_alicloud as alicloud
name_regex = alicloud.ens.get_key_pairs(version="example_value",
name_regex="^my-KeyPair")
pulumi.export("ensKeyPairId1", name_regex.pairs[0].id)Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var nameRegex = AliCloud.Ens.GetKeyPairs.Invoke(new()
{
Version = "example_value",
NameRegex = "^my-KeyPair",
});
return new Dictionary<string, object?>
{
["ensKeyPairId1"] = nameRegex.Apply(getKeyPairsResult => getKeyPairsResult.Pairs[0]?.Id),
};
});Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ens"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
nameRegex, err := ens.GetKeyPairs(ctx, &ens.GetKeyPairsArgs{
Version: "example_value",
NameRegex: pulumi.StringRef("^my-KeyPair"),
}, nil)
if err != nil {
return err
}
ctx.Export("ensKeyPairId1", nameRegex.Pairs[0].Id)
return nil
})
}Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ens.EnsFunctions;
import com.pulumi.alicloud.ens.inputs.GetKeyPairsArgs;
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 nameRegex = EnsFunctions.getKeyPairs(GetKeyPairsArgs.builder()
.version("example_value")
.nameRegex("^my-KeyPair")
.build());
ctx.export("ensKeyPairId1", nameRegex.applyValue(getKeyPairsResult -> getKeyPairsResult.pairs()[0].id()));
}
}Content copied to clipboard
variables:
nameRegex:
fn::invoke:
Function: alicloud:ens:getKeyPairs
Arguments:
version: example_value
nameRegex: ^my-KeyPair
outputs:
ensKeyPairId1: ${nameRegex.pairs[0].id}Content copied to clipboard
Return
A collection of values returned by getKeyPairs.
Parameters
argument
A collection of arguments for invoking getKeyPairs.
suspend fun getKeyPairs(keyPairName: String? = null, nameRegex: String? = null, outputFile: String? = null, version: String): GetKeyPairsResult
Return
A collection of values returned by getKeyPairs.
See also
Parameters
key Pair Name
The name of the key pair.
name Regex
A regex string to filter results by Key Pair name.
output File
File name where to save data source results (after running pulumi preview).
version
The version number.
suspend fun getKeyPairs(argument: suspend GetKeyPairsPlainArgsBuilder.() -> Unit): GetKeyPairsResult
Return
A collection of values returned by getKeyPairs.
See also
Parameters
argument
Builder for com.pulumi.alicloud.ens.kotlin.inputs.GetKeyPairsPlainArgs.