Skip to content

logs: encryption using Alias stopped working #35520

@Frogtime

Description

@Frogtime

Describe the bug

Since upgrading to CDK v2.215.0 encrypting of log.LogGroup stopped working when using kms.Alias as encyption_key. When I use kms.Key instead, it works as intended.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

2.214.0

Expected Behavior

Since no change is mentioned in the change logs, I would expected that log.LogGroup can be encrypted using kms.Alias as in v2.214.0.

Current Behavior

Running cdk synth results in the following error:
RuntimeError: Cannot access aliasTargetKey on an Alias imported by Alias.fromAliasName().

Reproduction Steps

Here is a minimal working example:

from aws_cdk import Stack
from aws_cdk import aws_kms as kms
from aws_cdk import aws_logs as logs

from constructs import Construct

class CdkTestStack(Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        alias = kms.Alias.from_alias_name(
            self,
            "KmsAlias",
            alias_name="alias/some-alias",
        )

        logs.LogGroup(
            self,
            "LogGroup",
            encryption_key=alias,
        )

and then run cdk synth.

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.215.0

AWS CDK CLI version

2.1029.2

Node.js Version

v22.14.0

OS

macOS 26

Language

Python

Language Version

3.13

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-logsRelated to Amazon CloudWatch LogsbugThis issue is a bug.closed-for-stalenessThis issue was automatically closed because it hadn't received any attention in a while.p1potential-regressionMarking this issue as a potential regression to be checked by team memberresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions