Skip to content
v2.278.0

KeyLookupOptions Struct ​

Properties for looking up an existing Key.

Example ​

ts
const myKeyLookup = kms.Key.fromLookup(this, 'MyKeyLookup', {
  aliasName: 'alias/KeyAlias',
});

const role = new iam.Role(this, 'MyRole', {
  assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
myKeyLookup.grantEncryptDecrypt(role);
python
my_key_lookup = kms.Key.from_lookup(self, "MyKeyLookup",
    alias_name="alias/KeyAlias"
)

role = iam.Role(self, "MyRole",
    assumed_by=iam.ServicePrincipal("lambda.amazonaws.com")
)
my_key_lookup.grant_encrypt_decrypt(role)
java
IKey myKeyLookup = Key.fromLookup(this, "MyKeyLookup", KeyLookupOptions.builder()
        .aliasName("alias/KeyAlias")
        .build());

Role role = Role.Builder.create(this, "MyRole")
        .assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
        .build();
myKeyLookup.grantEncryptDecrypt(role);
csharp
// Install: dotnet add package Amazon.CDK.Lib
var myKeyLookup = Key.FromLookup(this, "MyKeyLookup", new KeyLookupOptions {
    AliasName = "alias/KeyAlias"
});

var role = new Role(this, "MyRole", new RoleProps {
    AssumedBy = new ServicePrincipal("lambda.amazonaws.com")
});
myKeyLookup.GrantEncryptDecrypt(role);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
myKeyLookup := kms.Key_FromLookup(this, jsii.String("MyKeyLookup"), &KeyLookupOptions{
	AliasName: jsii.String("alias/KeyAlias"),
})

role := iam.NewRole(this, jsii.String("MyRole"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("lambda.amazonaws.com")),
})
myKeyLookup.GrantEncryptDecrypt(role)

Properties ​

aliasNamestringalias_namestraliasNameStringAliasNamestringAliasName*string required #
The alias name of the Key.

Must be in the format alias/<AliasName>.

returnDummyKeyOnMissingoptionalbooleanreturn_dummy_key_on_missingoptionalboolreturnDummyKeyOnMissingoptionalBooleanReturnDummyKeyOnMissingoptionalboolReturnDummyKeyOnMissingoptional*bool = false #
Whether to return a dummy key if the key was not found.
notes

If it is set to true and the key was not found, a dummy key with a key id '1234abcd-12ab-34cd-56ef-1234567890ab' will be returned. The value of the dummy key id can also be referenced using the Key.DEFAULT_DUMMY_KEY_ID variable, and you can check if the key is a dummy key by using the Key.isLookupDummy() method.