get Ecs Key Pairs
This data source provides the Ecs Key Pairs of the current Alibaba Cloud user.
NOTE: Available in v1.121.0+.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const example = alicloud.ecs.getEcsKeyPairs({
ids: ["key_pair_name"],
nameRegex: "key_pair_name",
});
export const firstEcsKeyPairId = example.then(example => example.pairs?.[0]?.id);
Content copied to clipboard
import pulumi
import pulumi_alicloud as alicloud
example = alicloud.ecs.get_ecs_key_pairs(ids=["key_pair_name"],
name_regex="key_pair_name")
pulumi.export("firstEcsKeyPairId", example.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 example = AliCloud.Ecs.GetEcsKeyPairs.Invoke(new()
{
Ids = new[]
{
"key_pair_name",
},
NameRegex = "key_pair_name",
});
return new Dictionary<string, object?>
{
["firstEcsKeyPairId"] = example.Apply(getEcsKeyPairsResult => getEcsKeyPairsResult.Pairs[0]?.Id),
};
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := ecs.GetEcsKeyPairs(ctx, &ecs.GetEcsKeyPairsArgs{
Ids: []string{
"key_pair_name",
},
NameRegex: pulumi.StringRef("key_pair_name"),
}, nil)
if err != nil {
return err
}
ctx.Export("firstEcsKeyPairId", example.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.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetEcsKeyPairsArgs;
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 example = EcsFunctions.getEcsKeyPairs(GetEcsKeyPairsArgs.builder()
.ids("key_pair_name")
.nameRegex("key_pair_name")
.build());
ctx.export("firstEcsKeyPairId", example.applyValue(getEcsKeyPairsResult -> getEcsKeyPairsResult.pairs()[0].id()));
}
}
Content copied to clipboard
variables:
example:
fn::invoke:
function: alicloud:ecs:getEcsKeyPairs
arguments:
ids:
- key_pair_name
nameRegex: key_pair_name
outputs:
firstEcsKeyPairId: ${example.pairs[0].id}
Content copied to clipboard
Return
A collection of values returned by getEcsKeyPairs.
Parameters
argument
A collection of arguments for invoking getEcsKeyPairs.
suspend fun getEcsKeyPairs(fingerPrint: String? = null, ids: List<String>? = null, nameRegex: String? = null, outputFile: String? = null, resourceGroupId: String? = null, tags: Map<String, String>? = null): GetEcsKeyPairsResult
Return
A collection of values returned by getEcsKeyPairs.
Parameters
finger Print
The finger print of the key pair.
ids
A list of Key Pair IDs.
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
).
resource Group Id
The resource group Id.
tags
See also
suspend fun getEcsKeyPairs(argument: suspend GetEcsKeyPairsPlainArgsBuilder.() -> Unit): GetEcsKeyPairsResult
Return
A collection of values returned by getEcsKeyPairs.
Parameters
argument
Builder for com.pulumi.alicloud.ecs.kotlin.inputs.GetEcsKeyPairsPlainArgs.