Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi
alicloud.kms.getKeys
Explore with Pulumi AI
This data source provides a list of KMS keys in an Alibaba Cloud account according to the specified filters.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
// Declare the data source
const kmsKeysDs = alicloud.kms.getKeys({
    descriptionRegex: "Hello KMS",
    outputFile: "kms_keys.json",
});
export const firstKeyId = kmsKeysDs.then(kmsKeysDs => kmsKeysDs.keys?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
# Declare the data source
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)
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 {
		// Declare the data source
		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
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() => 
{
    // Declare the data source
    var kmsKeysDs = AliCloud.Kms.GetKeys.Invoke(new()
    {
        DescriptionRegex = "Hello KMS",
        OutputFile = "kms_keys.json",
    });
    return new Dictionary<string, object?>
    {
        ["firstKeyId"] = kmsKeysDs.Apply(getKeysResult => getKeysResult.Keys[0]?.Id),
    };
});
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) {
        // Declare the data source
        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()));
    }
}
variables:
  # Declare the data source
  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 dictionaryThe following arguments are supported:
- Description
Regex string - A regex string to filter the results by the KMS key description.
 - Enable
Details bool - Filters string
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - Ids List<string>
 - A list of KMS key IDs.
 - Output
File string - File name where to save data source results (after running 
pulumi preview). - Status string
 - Filter the results by status of the KMS keys. Valid values: 
Enabled,Disabled,PendingDeletion. 
- Description
Regex string - A regex string to filter the results by the KMS key description.
 - Enable
Details bool - Filters string
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - Ids []string
 - A list of KMS key IDs.
 - Output
File string - File name where to save data source results (after running 
pulumi preview). - Status string
 - Filter the results by status of the KMS keys. Valid values: 
Enabled,Disabled,PendingDeletion. 
- description
Regex String - A regex string to filter the results by the KMS key description.
 - enable
Details Boolean - filters String
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - ids List<String>
 - A list of KMS key IDs.
 - output
File String - File name where to save data source results (after running 
pulumi preview). - status String
 - Filter the results by status of the KMS keys. Valid values: 
Enabled,Disabled,PendingDeletion. 
- description
Regex string - A regex string to filter the results by the KMS key description.
 - enable
Details boolean - filters string
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - ids string[]
 - A list of KMS key IDs.
 - output
File string - File name where to save data source results (after running 
pulumi preview). - 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
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - ids Sequence[str]
 - A list of KMS key IDs.
 - output_
file str - File name where to save data source results (after running 
pulumi preview). - status str
 - Filter the results by status of the KMS keys. Valid values: 
Enabled,Disabled,PendingDeletion. 
- description
Regex String - A regex string to filter the results by the KMS key description.
 - enable
Details Boolean - filters String
 - The CMK filter. The filter consists of one or more key-value pairs. You can specify a maximum of 10 key-value pairs. More details see API ListKeys.
 - ids List<String>
 - A list of KMS key IDs.
 - output
File String - File name where to save data source results (after running 
pulumi preview). - 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.
Ali Cloud. Kms. Outputs. Get Keys Key>  - A list of KMS keys. Each element contains the following attributes:
 - Description
Regex string - Enable
Details bool - Filters string
 - Output
File string - Status string
 - Status of the key. Possible values: 
Enabled,DisabledandPendingDeletion. 
- Id string
 - The provider-assigned unique ID for this managed resource.
 - Ids []string
 - A list of KMS key IDs.
 - Keys
[]Get
Keys Key  - A list of KMS keys. Each element contains the following attributes:
 - Description
Regex string - Enable
Details bool - Filters string
 - Output
File string - Status string
 - Status of the key. Possible values: 
Enabled,DisabledandPendingDeletion. 
- id String
 - The provider-assigned unique ID for this managed resource.
 - ids List<String>
 - A list of KMS key IDs.
 - keys
List<Get
Keys Key>  - A list of KMS keys. Each element contains the following attributes:
 - description
Regex String - enable
Details Boolean - filters String
 - output
File String - status String
 - Status of the key. Possible values: 
Enabled,DisabledandPendingDeletion. 
- id string
 - The provider-assigned unique ID for this managed resource.
 - ids string[]
 - A list of KMS key IDs.
 - keys
Get
Keys Key[]  - A list of KMS keys. Each element contains the following attributes:
 - description
Regex string - enable
Details boolean - filters string
 - output
File string - status string
 - Status of the key. Possible values: 
Enabled,DisabledandPendingDeletion. 
- id str
 - The provider-assigned unique ID for this managed resource.
 - ids Sequence[str]
 - A list of KMS key IDs.
 - keys
Sequence[Get
Keys Key]  - 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,DisabledandPendingDeletion. 
- 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:
 - description
Regex String - enable
Details Boolean - filters String
 - output
File String - status String
 - Status of the key. Possible values: 
Enabled,DisabledandPendingDeletion. 
Supporting Types
GetKeysKey  
- Arn string
 - The Alibaba Cloud Resource Name (ARN) of the key.
 - Automatic
Rotation string - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - Creation
Date string - Creation date of key.
 - Creator string
 - The owner of the key.
 - Delete
Date string - Deletion date of key.
 - Description string
 - Description of the key.
 - Id string
 - ID of the key.
 - Key
Id string - (Available in 1.123.1+) ID of the key.
 - Key
Spec string - (Available in 1.123.1+) The type of the CMK.
 - Key
Usage string - (Available in 1.123.1+) The usage of CMK.
 - Last
Rotation stringDate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - Material
Expire stringTime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - Next
Rotation stringDate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - Origin string
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - Primary
Key stringVersion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - Protection
Level string - (Available in 1.123.1+) The protection level of the CMK.
 - Rotation
Interval string - (Available in 1.123.1+) The period of automatic key rotation.
 - 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.
 - Automatic
Rotation string - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - Creation
Date string - Creation date of key.
 - Creator string
 - The owner of the key.
 - Delete
Date string - Deletion date of key.
 - Description string
 - Description of the key.
 - Id string
 - ID of the key.
 - Key
Id string - (Available in 1.123.1+) ID of the key.
 - Key
Spec string - (Available in 1.123.1+) The type of the CMK.
 - Key
Usage string - (Available in 1.123.1+) The usage of CMK.
 - Last
Rotation stringDate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - Material
Expire stringTime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - Next
Rotation stringDate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - Origin string
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - Primary
Key stringVersion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - Protection
Level string - (Available in 1.123.1+) The protection level of the CMK.
 - Rotation
Interval string - (Available in 1.123.1+) The period of automatic key rotation.
 - 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.
 - automatic
Rotation String - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - creation
Date String - Creation date of key.
 - creator String
 - The owner of the key.
 - delete
Date String - Deletion date of key.
 - description String
 - Description of the key.
 - id String
 - ID of the key.
 - key
Id String - (Available in 1.123.1+) ID of the key.
 - key
Spec String - (Available in 1.123.1+) The type of the CMK.
 - key
Usage String - (Available in 1.123.1+) The usage of CMK.
 - last
Rotation StringDate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - material
Expire StringTime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - next
Rotation StringDate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - origin String
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - primary
Key StringVersion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - protection
Level String - (Available in 1.123.1+) The protection level of the CMK.
 - rotation
Interval String - (Available in 1.123.1+) The period of automatic key rotation.
 - 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.
 - automatic
Rotation string - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - creation
Date string - Creation date of key.
 - creator string
 - The owner of the key.
 - delete
Date string - Deletion date of key.
 - description string
 - Description of the key.
 - id string
 - ID of the key.
 - key
Id string - (Available in 1.123.1+) ID of the key.
 - key
Spec string - (Available in 1.123.1+) The type of the CMK.
 - key
Usage string - (Available in 1.123.1+) The usage of CMK.
 - last
Rotation stringDate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - material
Expire stringTime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - next
Rotation stringDate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - origin string
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - primary
Key stringVersion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - protection
Level string - (Available in 1.123.1+) The protection level of the CMK.
 - rotation
Interval string - (Available in 1.123.1+) The period of automatic key rotation.
 - 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 - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - creation_
date str - Creation date of key.
 - creator str
 - The owner of the key.
 - delete_
date str - Deletion date of key.
 - description str
 - Description of the key.
 - id str
 - ID of the key.
 - key_
id str - (Available in 1.123.1+) ID of the key.
 - key_
spec str - (Available in 1.123.1+) The type of the CMK.
 - key_
usage str - (Available in 1.123.1+) The usage of CMK.
 - last_
rotation_ strdate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - material_
expire_ strtime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - next_
rotation_ strdate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - origin str
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - primary_
key_ strversion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - protection_
level str - (Available in 1.123.1+) The protection level of the CMK.
 - rotation_
interval str - (Available in 1.123.1+) The period of automatic key rotation.
 - 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.
 - automatic
Rotation String - (Available in 1.123.1+) Specifies whether to enable automatic key rotation.
 - creation
Date String - Creation date of key.
 - creator String
 - The owner of the key.
 - delete
Date String - Deletion date of key.
 - description String
 - Description of the key.
 - id String
 - ID of the key.
 - key
Id String - (Available in 1.123.1+) ID of the key.
 - key
Spec String - (Available in 1.123.1+) The type of the CMK.
 - key
Usage String - (Available in 1.123.1+) The usage of CMK.
 - last
Rotation StringDate  - (Available in 1.123.1+) The date and time the last rotation was performed.
 - material
Expire StringTime  - (Available in 1.123.1+) The time and date the key material for the CMK expires.
 - next
Rotation StringDate  - (Available in 1.123.1+) The time the next rotation is scheduled for execution.
 - origin String
 - (Available in 1.123.1+) The source of the key material for the CMK.
 - primary
Key StringVersion  - (Available in 1.123.1+) The ID of the current primary key version of the symmetric CMK.
 - protection
Level String - (Available in 1.123.1+) The protection level of the CMK.
 - rotation
Interval String - (Available in 1.123.1+) The period of automatic key rotation.
 - status String
 - Filter the results by status of the KMS keys. Valid values: 
Enabled,Disabled,PendingDeletion. 
Package Details
- Repository
 - Alibaba Cloud pulumi/pulumi-alicloud
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
alicloudTerraform Provider.