interface AliasProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.KMS.AliasProps |
Java | software.amazon.awscdk.services.kms.AliasProps |
Python | aws_cdk.aws_kms.AliasProps |
TypeScript (source) | @aws-cdk/aws-kms » AliasProps |
Construction properties for a KMS Key Alias object.
Example
/**
* Stack that defines the key
*/
class KeyStack extends cdk.Stack {
public readonly key: kms.Key;
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
this.key = new kms.Key(this, 'MyKey', { removalPolicy: cdk.RemovalPolicy.DESTROY });
}
}
interface UseStackProps extends cdk.StackProps {
key: kms.IKey; // Use IKey here
}
/**
* Stack that uses the key
*/
class UseStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props: UseStackProps) {
super(scope, id, props);
// Use the IKey object here.
new kms.Alias(this, 'Alias', {
aliasName: 'alias/foo',
targetKey: props.key,
});
}
}
const keyStack = new KeyStack(app, 'KeyStack');
new UseStack(app, 'UseStack', { key: keyStack.key });
Properties
Name | Type | Description |
---|---|---|
alias | string | The name of the alias. |
target | IKey | The ID of the key for which you are creating the alias. |
removal | Removal | Policy to apply when the alias is removed from this stack. |
aliasName
Type:
string
The name of the alias.
The name must start with alias followed by a forward slash, such as alias/. You can't specify aliases that begin with alias/AWS. These aliases are reserved.
targetKey
Type:
IKey
The ID of the key for which you are creating the alias.
Specify the key's globally unique identifier or Amazon Resource Name (ARN). You can't specify another alias.
removalPolicy?
Type:
Removal
(optional, default: The alias will be deleted)
Policy to apply when the alias is removed from this stack.