IKey

class aws_cdk.aws_kms.IKey(*args, **kwargs)

Bases: IResource, Protocol

A KMS Key, either managed by this CDK app, or imported.

Methods

add_alias(alias)

Defines a new alias for the key.

Parameters:

alias (str) –

Return type:

Alias

add_to_resource_policy(statement, allow_no_op=None)

Adds a statement to the KMS key resource policy.

Parameters:
  • statement (PolicyStatement) – The policy statement to add.

  • allow_no_op (Optional[bool]) – If this is set to false and there is no policy defined (i.e. external key), the operation will fail. Otherwise, it will no-op.

Return type:

AddToResourcePolicyResult

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

grant(grantee, *actions)

Grant the indicated permissions on this key to the given principal.

Parameters:
Return type:

Grant

grant_decrypt(grantee)

Grant decryption permissions using this key to the given principal.

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_encrypt(grantee)

Grant encryption permissions using this key to the given principal.

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_encrypt_decrypt(grantee)

Grant encryption and decryption permissions using this key to the given principal.

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_generate_mac(grantee)

Grant permissions to generating MACs to the given principal.

Parameters:

grantee (IGrantable) –

Return type:

Grant

grant_verify_mac(grantee)

Grant permissions to verifying MACs to the given principal.

Parameters:

grantee (IGrantable) –

Return type:

Grant

Attributes

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

key_arn

The ARN of the key.

Attribute:

true

key_id

1234abcd-12ab-34cd-56ef-1234567890ab).

Attribute:

true

Type:

The ID of the key (the part that looks something like

node

The tree node.

stack

The stack in which this resource is defined.