Alibaba Cloud

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

getKeys

This data source provides a list of KMS keys in an Alibaba Cloud account according to the specified filters.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var kmsKeysDs = Output.Create(AliCloud.Kms.GetKeys.InvokeAsync(new AliCloud.Kms.GetKeysArgs
        {
            DescriptionRegex = "Hello KMS",
            OutputFile = "kms_keys.json",
        }));
        this.FirstKeyId = kmsKeysDs.Apply(kmsKeysDs => kmsKeysDs.Keys?[0]?.Id);
    }

    [Output("firstKeyId")]
    public Output<string> FirstKeyId { get; set; }
}
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		kmsKeysDs, err := kms.GetKeys(ctx, &kms.GetKeysArgs{
			DescriptionRegex: pulumi.StringRef("Hello KMS"),
			OutputFile:       pulumi.StringRef("kms_keys.json"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("firstKeyId", kmsKeysDs.Keys[0].Id)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.kms.KmsFunctions;
import com.pulumi.alicloud.kms.inputs.GetKeysArgs;
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 kmsKeysDs = KmsFunctions.getKeys(GetKeysArgs.builder()
            .descriptionRegex("Hello KMS")
            .outputFile("kms_keys.json")
            .build());

        ctx.export("firstKeyId", kmsKeysDs.applyValue(getKeysResult -> getKeysResult.keys()[0].id()));
    }
}
import pulumi
import pulumi_alicloud as alicloud

kms_keys_ds = alicloud.kms.get_keys(description_regex="Hello KMS",
    output_file="kms_keys.json")
pulumi.export("firstKeyId", kms_keys_ds.keys[0].id)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

// Declare the data source
const kmsKeysDs = pulumi.output(alicloud.kms.getKeys({
    descriptionRegex: "Hello KMS",
    outputFile: "kms_keys.json",
}));

export const firstKeyId = kmsKeysDs.keys[0].id;
variables:
  kmsKeysDs:
    Fn::Invoke:
      Function: alicloud:kms:getKeys
      Arguments:
        descriptionRegex: Hello KMS
        outputFile: kms_keys.json
outputs:
  firstKeyId: ${kmsKeysDs.keys[0].id}

Using getKeys

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 getKeys(args: GetKeysArgs, opts?: InvokeOptions): Promise<GetKeysResult>
function getKeysOutput(args: GetKeysOutputArgs, opts?: InvokeOptions): Output<GetKeysResult>
def get_keys(description_regex: Optional[str] = None,
             enable_details: Optional[bool] = None,
             filters: Optional[str] = None,
             ids: Optional[Sequence[str]] = None,
             output_file: Optional[str] = None,
             status: Optional[str] = None,
             opts: Optional[InvokeOptions] = None) -> GetKeysResult
def get_keys_output(description_regex: Optional[pulumi.Input[str]] = None,
             enable_details: Optional[pulumi.Input[bool]] = None,
             filters: Optional[pulumi.Input[str]] = None,
             ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
             output_file: Optional[pulumi.Input[str]] = None,
             status: Optional[pulumi.Input[str]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetKeysResult]
func GetKeys(ctx *Context, args *GetKeysArgs, opts ...InvokeOption) (*GetKeysResult, error)
func GetKeysOutput(ctx *Context, args *GetKeysOutputArgs, opts ...InvokeOption) GetKeysResultOutput

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

public static class GetKeys 
{
    public static Task<GetKeysResult> InvokeAsync(GetKeysArgs args, InvokeOptions? opts = null)
    public static Output<GetKeysResult> Invoke(GetKeysInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetKeysResult> getKeys(GetKeysArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: alicloud:kms/getKeys:getKeys
  Arguments:
    # Arguments dictionary

The following arguments are supported:

DescriptionRegex string

A regex string to filter the results by the KMS key description.

EnableDetails bool
Filters string
Ids List<string>

A list of KMS key IDs.

OutputFile string
Status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

DescriptionRegex string

A regex string to filter the results by the KMS key description.

EnableDetails bool
Filters string
Ids []string

A list of KMS key IDs.

OutputFile string
Status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

descriptionRegex String

A regex string to filter the results by the KMS key description.

enableDetails Boolean
filters String
ids List<String>

A list of KMS key IDs.

outputFile String
status String

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

descriptionRegex string

A regex string to filter the results by the KMS key description.

enableDetails boolean
filters string
ids string[]

A list of KMS key IDs.

outputFile string
status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

description_regex str

A regex string to filter the results by the KMS key description.

enable_details bool
filters str
ids Sequence[str]

A list of KMS key IDs.

output_file str
status str

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

descriptionRegex String

A regex string to filter the results by the KMS key description.

enableDetails Boolean
filters String
ids List<String>

A list of KMS key IDs.

outputFile String
status String

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

getKeys Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

A list of KMS key IDs.

Keys List<Pulumi.AliCloud.Kms.Outputs.GetKeysKey>

A list of KMS keys. Each element contains the following attributes:

DescriptionRegex string
EnableDetails bool
Filters string
OutputFile string
Status string

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

Id string

The provider-assigned unique ID for this managed resource.

Ids []string

A list of KMS key IDs.

Keys []GetKeysKey

A list of KMS keys. Each element contains the following attributes:

DescriptionRegex string
EnableDetails bool
Filters string
OutputFile string
Status string

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of KMS key IDs.

keys List<GetKeysKey>

A list of KMS keys. Each element contains the following attributes:

descriptionRegex String
enableDetails Boolean
filters String
outputFile String
status String

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

id string

The provider-assigned unique ID for this managed resource.

ids string[]

A list of KMS key IDs.

keys GetKeysKey[]

A list of KMS keys. Each element contains the following attributes:

descriptionRegex string
enableDetails boolean
filters string
outputFile string
status string

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

id str

The provider-assigned unique ID for this managed resource.

ids Sequence[str]

A list of KMS key IDs.

keys Sequence[GetKeysKey]

A list of KMS keys. Each element contains the following attributes:

description_regex str
enable_details bool
filters str
output_file str
status str

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of KMS key IDs.

keys List<Property Map>

A list of KMS keys. Each element contains the following attributes:

descriptionRegex String
enableDetails Boolean
filters String
outputFile String
status String

Status of the key. Possible values: Enabled, Disabled and PendingDeletion.

Supporting Types

GetKeysKey

Arn string

The Alibaba Cloud Resource Name (ARN) of the key.

AutomaticRotation string
CreationDate string

Creation date of key.

Creator string

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
DeleteDate string

Deletion date of key.

Description string

Description of the key.

Id string

ID of the key.

KeyId string
KeySpec string
KeyUsage string
LastRotationDate string
MaterialExpireTime string
NextRotationDate string
Origin string
PrimaryKeyVersion string
ProtectionLevel string
RotationInterval string
Status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

Arn string

The Alibaba Cloud Resource Name (ARN) of the key.

AutomaticRotation string
CreationDate string

Creation date of key.

Creator string

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
DeleteDate string

Deletion date of key.

Description string

Description of the key.

Id string

ID of the key.

KeyId string
KeySpec string
KeyUsage string
LastRotationDate string
MaterialExpireTime string
NextRotationDate string
Origin string
PrimaryKeyVersion string
ProtectionLevel string
RotationInterval string
Status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

arn String

The Alibaba Cloud Resource Name (ARN) of the key.

automaticRotation String
creationDate String

Creation date of key.

creator String

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
deleteDate String

Deletion date of key.

description String

Description of the key.

id String

ID of the key.

keyId String
keySpec String
keyUsage String
lastRotationDate String
materialExpireTime String
nextRotationDate String
origin String
primaryKeyVersion String
protectionLevel String
rotationInterval String
status String

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

arn string

The Alibaba Cloud Resource Name (ARN) of the key.

automaticRotation string
creationDate string

Creation date of key.

creator string

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
deleteDate string

Deletion date of key.

description string

Description of the key.

id string

ID of the key.

keyId string
keySpec string
keyUsage string
lastRotationDate string
materialExpireTime string
nextRotationDate string
origin string
primaryKeyVersion string
protectionLevel string
rotationInterval string
status string

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

arn str

The Alibaba Cloud Resource Name (ARN) of the key.

automatic_rotation str
creation_date str

Creation date of key.

creator str

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
delete_date str

Deletion date of key.

description str

Description of the key.

id str

ID of the key.

key_id str
key_spec str
key_usage str
last_rotation_date str
material_expire_time str
next_rotation_date str
origin str
primary_key_version str
protection_level str
rotation_interval str
status str

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

arn String

The Alibaba Cloud Resource Name (ARN) of the key.

automaticRotation String
creationDate String

Creation date of key.

creator String

The owner of the key.

  • automatic_rotation -(Available in 1.123.1+) Specifies whether to enable automatic key rotation.
  • key_id -(Available in 1.123.1+) ID of the key.
  • key_spec -(Available in 1.123.1+) The type of the CMK.
  • key_usage -(Available in 1.123.1+) The usage of CMK.
  • last_rotation_date -(Available in 1.123.1+) The date and time the last rotation was performed.
  • material_expire_time -(Available in 1.123.1+) The time and date the key material for the CMK expires.
  • next_rotation_date -(Available in 1.123.1+) The time the next rotation is scheduled for execution.
  • origin -(Available in 1.123.1+) The source of the key material for the CMK.
  • protection_level -(Available in 1.123.1+) The protection level of the CMK.
  • rotation_interval -(Available in 1.123.1+) The period of automatic key rotation.
  • primary_key_version -(Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
deleteDate String

Deletion date of key.

description String

Description of the key.

id String

ID of the key.

keyId String
keySpec String
keyUsage String
lastRotationDate String
materialExpireTime String
nextRotationDate String
origin String
primaryKeyVersion String
protectionLevel String
rotationInterval String
status String

Filter the results by status of the KMS keys. Valid values: Enabled, Disabled, PendingDeletion.

Package Details

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

This Pulumi package is based on the alicloud Terraform Provider.