Skip to content

(logs): LogGroup.grant() and grantRead() do not include the log group ARN #39561

Open

Description

@1992chenlu

Describe the bug

LogGroup.grant() and LogGroup.grantRead() use only the log group ARN that ends in :* as the resource of the generated statement. The plain log group ARN is not included.

Expected Behavior

Statements created by LogGroup.grant() and LogGroup.grantRead() list both the plain log group ARN (arn:<partition>:logs:<region>:<account>:log-group:<name>) and the :* ARN.

Current Behavior

Only arn:<partition>:logs:<region>:<account>:log-group:<name>:* is listed.

Reproduction Steps

const logGroup = new logs.LogGroup(stack, 'LogGroup');
const role = new iam.Role(stack, 'Role', { assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com') });
logGroup.grant(role, 'logs:DescribeLogStreams');

Possible Solution

Pass both ARNs as resourceArns in LogGroupBase.grant(), including for log groups imported by name or by ARN.

CDK version used

main

Environment details (OS name and version, etc.)

N/A

Activity

  1. pahud commented on Oct 30, 2026

    @pahud
    Contributor

    Hi @1992chenlu,

    Issue at a Glance:

    ┌──────────────────────────────┐     ┌──────────────────────────────┐
    │ LogGroup.grant(role,         │ ──> │ IAM statement gets only the  │
    │   'logs:DescribeLogStreams') │     │ ':*' log group ARN           │
    └──────────────────────────────┘     └──────────────────────────────┘
                                                      │
                                                      v
                                         ┌──────────────────────────────┐
                                         │ Plain log group ARN missing. │
                                         │ DescribeLogStreams is a      │
                                         │ group-level action.          │
                                         └──────────────────────────────┘
    

    I reproduced this with cdk synth on 2.1.0 (the oldest tag I checked) and 2.275.0 (latest). I did not deploy. In both, the logs:DescribeLogStreams statement has one resource: the Fn::GetAtt ... Arn of the log group, with no plain log group ARN. grants.read() shows the same.

    The :* suffix is intentional for stream actions, per the comment in the code:

    public grant(grantee: iam.IGrantable, ...actions: string[]) {
    return iam.Grant.addToPrincipalOrResource({
    grantee,
    actions,
    // A LogGroup ARN out of CloudFormation already includes a ':*' at the end to include the log streams under the group.
    // See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#w2ab1c21c10c63c43c11
    resourceArns: [this.logGroupArn],
    resource: this,
    });
    }

    Draft PR #39559 targets this. It changes grant() and a helper getter in log-group.ts. I did not run synth after that change, so I cannot say whether grants.read() is also fixed.

    Passing both ARNs to every action would grant more than needed, since stream actions such as PutLogEvents would then apply to the whole log group. The fix should map each action to the right resource type.

  2. added
    effort/mediumMedium work item – several days of effort
    feature-requestA feature should be added or improved.
    and removed
    needs-triageThis issue or PR still needs to be triaged.
    on Oct 30, 2026
  3. changed the title [-](logs): LogGroup.grant() does not include the log group ARN[/-] [+](logs): LogGroup.grant() and grantRead() do not include the log group ARN[/+] on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-logsRelated to Amazon CloudWatch Logseffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions