interface IKey
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.KMS.IKey |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awskms#IKey |
Java | software.amazon.awscdk.services.kms.IKey |
Python | aws_cdk.aws_kms.IKey |
TypeScript (source) | aws-cdk-lib » aws_kms » IKey |
Obtainable from
Key
.fromCfnKey()
, Key
.fromKeyArn()
, Key
.fromLookup()
A KMS Key, either managed by this CDK app, or imported.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
key | string | The ARN of the key. |
key | string | The ID of the key (the part that looks something like: 1234abcd-12ab-34cd-56ef-1234567890ab). |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
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.
keyArn
Type:
string
The ARN of the key.
keyId
Type:
string
The ID of the key (the part that looks something like: 1234abcd-12ab-34cd-56ef-1234567890ab).
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
add | Defines a new alias for the key. |
add | Adds a statement to the KMS key resource policy. |
apply | Apply the given removal policy to this resource. |
grant(grantee, ...actions) | Grant the indicated permissions on this key to the given principal. |
grant | Grant decryption permissions using this key to the given principal. |
grant | Grant encryption permissions using this key to the given principal. |
grant | Grant encryption and decryption permissions using this key to the given principal. |
grant | Grant permissions to generating MACs to the given principal. |
grant | Grant permissions to verifying MACs to the given principal. |
Alias(alias)
addpublic addAlias(alias: string): Alias
Parameters
- alias
string
Returns
Defines a new alias for the key.
ToResourcePolicy(statement, allowNoOp?)
addpublic addToResourcePolicy(statement: PolicyStatement, allowNoOp?: boolean): AddToResourcePolicyResult
Parameters
- statement
Policy
— The policy statement to add.Statement - allowNoOp
boolean
— If this is set tofalse
and there is no policy defined (i.e. external key), the operation will fail. Otherwise, it will no-op.
Returns
Adds a statement to the KMS key resource policy.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantable
- actions
string
Returns
Grant the indicated permissions on this key to the given principal.
Decrypt(grantee)
grantpublic grantDecrypt(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant decryption permissions using this key to the given principal.
Encrypt(grantee)
grantpublic grantEncrypt(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant encryption permissions using this key to the given principal.
EncryptDecrypt(grantee)
grantpublic grantEncryptDecrypt(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant encryption and decryption permissions using this key to the given principal.
GenerateMac(grantee)
grantpublic grantGenerateMac(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant permissions to generating MACs to the given principal.
VerifyMac(grantee)
grantpublic grantVerifyMac(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant permissions to verifying MACs to the given principal.