AliasProps

class aws_cdk.aws_kms.AliasProps(*, alias_name, target_key, removal_policy=None)

Bases: object

Construction properties for a KMS Key Alias object.

Parameters:
  • alias_name (str) – 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.

  • target_key (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.

  • removal_policy (Optional[RemovalPolicy]) – Policy to apply when the alias is removed from this stack. Default: - The alias will be deleted

ExampleMetadata:

lit=test/integ.key-sharing.lit.ts infused

Example:

#
# Stack that defines the key
#
class KeyStack(cdk.Stack):

    def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)
        self.key = kms.Key(self, "MyKey", removal_policy=cdk.RemovalPolicy.DESTROY)

#
# Stack that uses the key
#
class UseStack(cdk.Stack):
    def __init__(self, scope, id, *, key, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None, analyticsReporting=None):
        super().__init__(scope, id, key=key, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

        # Use the IKey object here.
        kms.Alias(self, "Alias",
            alias_name="alias/foo",
            target_key=key
        )

key_stack = KeyStack(app, "KeyStack")
UseStack(app, "UseStack", key=key_stack.key)

Attributes

alias_name

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.

removal_policy

Policy to apply when the alias is removed from this stack.

Default:
  • The alias will be deleted

target_key

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.