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

alicloud.ecp.getKeyPairs

Explore with Pulumi AI

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

This data source provides the Ecp Key Pairs of the current Alibaba Cloud user.

NOTE: Available in v1.130.0+.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const ids = alicloud.ecp.getKeyPairs({});
export const ecpKeyPairId1 = ids.then(ids => ids.pairs?.[0]?.id);
const nameRegex = alicloud.ecp.getKeyPairs({
    nameRegex: "^my-KeyPair",
});
export const ecpKeyPairId2 = nameRegex.then(nameRegex => nameRegex.pairs?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

ids = alicloud.ecp.get_key_pairs()
pulumi.export("ecpKeyPairId1", ids.pairs[0].id)
name_regex = alicloud.ecp.get_key_pairs(name_regex="^my-KeyPair")
pulumi.export("ecpKeyPairId2", name_regex.pairs[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecp"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		ids, err := ecp.GetKeyPairs(ctx, &ecp.GetKeyPairsArgs{}, nil)
		if err != nil {
			return err
		}
		ctx.Export("ecpKeyPairId1", ids.Pairs[0].Id)
		nameRegex, err := ecp.GetKeyPairs(ctx, &ecp.GetKeyPairsArgs{
			NameRegex: pulumi.StringRef("^my-KeyPair"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("ecpKeyPairId2", nameRegex.Pairs[0].Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var ids = AliCloud.Ecp.GetKeyPairs.Invoke();

    var nameRegex = AliCloud.Ecp.GetKeyPairs.Invoke(new()
    {
        NameRegex = "^my-KeyPair",
    });

    return new Dictionary<string, object?>
    {
        ["ecpKeyPairId1"] = ids.Apply(getKeyPairsResult => getKeyPairsResult.Pairs[0]?.Id),
        ["ecpKeyPairId2"] = nameRegex.Apply(getKeyPairsResult => getKeyPairsResult.Pairs[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecp.EcpFunctions;
import com.pulumi.alicloud.ecp.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 ids = EcpFunctions.getKeyPairs();

        ctx.export("ecpKeyPairId1", ids.applyValue(getKeyPairsResult -> getKeyPairsResult.pairs()[0].id()));
        final var nameRegex = EcpFunctions.getKeyPairs(GetKeyPairsArgs.builder()
            .nameRegex("^my-KeyPair")
            .build());

        ctx.export("ecpKeyPairId2", nameRegex.applyValue(getKeyPairsResult -> getKeyPairsResult.pairs()[0].id()));
    }
}
Copy
variables:
  ids:
    fn::invoke:
      function: alicloud:ecp:getKeyPairs
      arguments: {}
  nameRegex:
    fn::invoke:
      function: alicloud:ecp:getKeyPairs
      arguments:
        nameRegex: ^my-KeyPair
outputs:
  ecpKeyPairId1: ${ids.pairs[0].id}
  ecpKeyPairId2: ${nameRegex.pairs[0].id}
Copy

Using getKeyPairs

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 getKeyPairs(args: GetKeyPairsArgs, opts?: InvokeOptions): Promise<GetKeyPairsResult>
function getKeyPairsOutput(args: GetKeyPairsOutputArgs, opts?: InvokeOptions): Output<GetKeyPairsResult>
Copy
def get_key_pairs(ids: Optional[Sequence[str]] = None,
                  key_pair_finger_print: Optional[str] = None,
                  name_regex: Optional[str] = None,
                  output_file: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetKeyPairsResult
def get_key_pairs_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                  key_pair_finger_print: Optional[pulumi.Input[str]] = None,
                  name_regex: Optional[pulumi.Input[str]] = None,
                  output_file: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetKeyPairsResult]
Copy
func GetKeyPairs(ctx *Context, args *GetKeyPairsArgs, opts ...InvokeOption) (*GetKeyPairsResult, error)
func GetKeyPairsOutput(ctx *Context, args *GetKeyPairsOutputArgs, opts ...InvokeOption) GetKeyPairsResultOutput
Copy

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

public static class GetKeyPairs 
{
    public static Task<GetKeyPairsResult> InvokeAsync(GetKeyPairsArgs args, InvokeOptions? opts = null)
    public static Output<GetKeyPairsResult> Invoke(GetKeyPairsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetKeyPairsResult> getKeyPairs(GetKeyPairsArgs args, InvokeOptions options)
public static Output<GetKeyPairsResult> getKeyPairs(GetKeyPairsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:ecp/getKeyPairs:getKeyPairs
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Ids Changes to this property will trigger replacement. List<string>
A list of Key Pair IDs. Its element value is same as Key Pair Name.
KeyPairFingerPrint Changes to this property will trigger replacement. string
The Private Key of the Fingerprint.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Key Pair 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 Key Pair IDs. Its element value is same as Key Pair Name.
KeyPairFingerPrint Changes to this property will trigger replacement. string
The Private Key of the Fingerprint.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Key Pair 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 Key Pair IDs. Its element value is same as Key Pair Name.
keyPairFingerPrint Changes to this property will trigger replacement. String
The Private Key of the Fingerprint.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by Key Pair 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 Key Pair IDs. Its element value is same as Key Pair Name.
keyPairFingerPrint Changes to this property will trigger replacement. string
The Private Key of the Fingerprint.
nameRegex Changes to this property will trigger replacement. string
A regex string to filter results by Key Pair 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 Key Pair IDs. Its element value is same as Key Pair Name.
key_pair_finger_print Changes to this property will trigger replacement. str
The Private Key of the Fingerprint.
name_regex Changes to this property will trigger replacement. str
A regex string to filter results by Key Pair 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 Key Pair IDs. Its element value is same as Key Pair Name.
keyPairFingerPrint Changes to this property will trigger replacement. String
The Private Key of the Fingerprint.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter results by Key Pair name.
outputFile String
File name where to save data source results (after running pulumi preview).

getKeyPairs Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
Names List<string>
Pairs List<Pulumi.AliCloud.Ecp.Outputs.GetKeyPairsPair>
KeyPairFingerPrint string
NameRegex string
OutputFile string
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
Names []string
Pairs []GetKeyPairsPair
KeyPairFingerPrint string
NameRegex string
OutputFile string
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
pairs List<GetKeyPairsPair>
keyPairFingerPrint String
nameRegex String
outputFile String
id string
The provider-assigned unique ID for this managed resource.
ids string[]
names string[]
pairs GetKeyPairsPair[]
keyPairFingerPrint string
nameRegex string
outputFile string
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
names Sequence[str]
pairs Sequence[GetKeyPairsPair]
key_pair_finger_print str
name_regex str
output_file str
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
names List<String>
pairs List<Property Map>
keyPairFingerPrint String
nameRegex String
outputFile String

Supporting Types

GetKeyPairsPair

Id This property is required. string
The ID of the Key Pair. Its value is same as Queue Name.
KeyPairFingerPrint This property is required. string
The Private Key of the Fingerprint.
KeyPairName This property is required. string
The Key Name.
Id This property is required. string
The ID of the Key Pair. Its value is same as Queue Name.
KeyPairFingerPrint This property is required. string
The Private Key of the Fingerprint.
KeyPairName This property is required. string
The Key Name.
id This property is required. String
The ID of the Key Pair. Its value is same as Queue Name.
keyPairFingerPrint This property is required. String
The Private Key of the Fingerprint.
keyPairName This property is required. String
The Key Name.
id This property is required. string
The ID of the Key Pair. Its value is same as Queue Name.
keyPairFingerPrint This property is required. string
The Private Key of the Fingerprint.
keyPairName This property is required. string
The Key Name.
id This property is required. str
The ID of the Key Pair. Its value is same as Queue Name.
key_pair_finger_print This property is required. str
The Private Key of the Fingerprint.
key_pair_name This property is required. str
The Key Name.
id This property is required. String
The ID of the Key Pair. Its value is same as Queue Name.
keyPairFingerPrint This property is required. String
The Private Key of the Fingerprint.
keyPairName This property is required. String
The Key Name.

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