moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

aws-events: Cannot grant `putEvents` to Service Principals #3

Closed moelasmar closed 2 months ago

moelasmar commented 2 months ago

Migrated from aws/aws-cdk#22080

Original issue by @arcrank on 2022-09-16T15:44:27Z

Describe the bug

When trying to grantPutEventsTo an AWS SP, there is a no-op, and no warnings or errors. I would expect if we added a grant to a iam.ServicePrincipal that the underlying grant/policy would be created. We can add an SP to the event bus in the console. Tracing back code I myself didn't necessary find a place where this would have failed, or I would have expected if this was not possible to give a failure message.

Expected Behavior

I would expect the template to have grant policies attached. If for some reason you weren't allowed to add SPs, I would expect a failure message and error.

Current Behavior

Nothing is logged to the terminal when synthing the template snippet is

 "Resources": {
  "bus707364D1": {
   "Type": "AWS::Events::EventBus",
   "Properties": {
    "Name": "MyCustomEventBus"
   },
   "Metadata": {
    "aws:cdk:path": "xxx/bus/Resource"
   }
  },
  "busMyArchiveF1010141": {
   "Type": "AWS::Events::Archive",
   "Properties": {
    "SourceArn": {
     "Fn::GetAtt": [
      "bus707364D1",
      "Arn"
     ]
    },
    "ArchiveName": "MyCustomEventBusArchive",
    "Description": "MyCustomerEventBus Archive",
    "EventPattern": {
     "account": [
      "264988854622"
     ]
    },
    "RetentionDays": 365
   },

Reproduction Steps

    const bus = new events.EventBus(this, 'bus', {
      eventBusName: 'MyCustomEventBus'
    });

    bus.archive('MyArchive', {
      archiveName: 'MyCustomEventBusArchive',
      description: 'MyCustomerEventBus Archive',
      eventPattern: {
        account: [cdk.Stack.of(this).account],
      },
      retention: cdk.Duration.days(365),
    });

    bus.grantPutEventsTo(new iam.ServicePrincipal('lambda.amazonaws.com'));

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.23.0

Framework Version

No response

Node.js Version

14

OS

MacOs/Linux

Language

Typescript

Language Version

No response

Other information

No response

moelasmar commented 2 months ago

This issue has been queued for processing by our automated system.

moelasmar commented 2 months ago
    ## Issue Processing Complete

    This issue has been processed successfully.

    You can view the processing results here: [Results](https://cdkgithubbugreproducersta-githubissueresultsbucket-anxrgpotfplp.s3.amazonaws.com/moelasmar/CodeQlDemoEcsIssue%233.txt?AWSAccessKeyId=ASIAQUFLP7FHUQVTCNLH&Signature=MOd7AwCHNWtQSUsLBK0CN15UyGk%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEJr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQCxUZsRhzoxemkeNGehqjH4WkUrVX7dE6dPkQJ05aiEdgIgI%2BYdEEJo6CFG6ZyH33rSS%2BKutWpMHMxMfLX2osvirigq5AQI4%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDGiZ%2BRchAvhoqByl8yq4BPdr1ODd%2FPO5W%2Bm4a3O4a69QCCsK1NnmSzb2f%2Fd2sLKsSVxEZf2UGg3pbX6D3wLFKgGKcQcIGdtKbSVYLukXsUzprrE%2FwdvD7vy0bmi4cu43Jacb364fMTBzNuCAgfPiT494M7ae3weRtePxM6LkuIS3dTj63cwZcXnW1lDOpy03wga2IlYFNPqpMzD3KuRWad%2FgtRWaZGvoWAzxjgn7vhy%2FV7eBq3T3GoUI6Cmmx%2FVcrfxqVZBzMQC%2FpDWbYXroSWRsd8m167JMgtgEgDIFseyeg1L3%2Bh1fbTn%2B34Zhk7Q57V01pyLFLQToCzaeyKW50lY18r1sPvPIYBrPyTxXLqriwO7yUi4Nqf19NO7aThbkfivjgyiQoMSvrSom3N8eK2cPGUY1QlXCEn93Jil5FiDfPMbQ9eeNPlWuPF2Qvim6G3Z%2FL08Eq69t0HyOvWMdgg0Y7OugGmfxoK7Uk2OROM9U7eIMkCXzLigEAZMh4yysXqEoa7Vxq5cV6o8GJXWH0IaUKavZx2YdsC6%2BGR6elAxyO7COiB2egZLvUJYOu6LIrUp4GrNGS4dHX9TaqkQSrjEiY123pIq%2Ft7dikOO0Fm7t85zr9H29SBIvh66eKqyYZdJ1LYyDQTjCbzVThTuxzdZ4W4LCdlr%2FuNUTU3Acp60wm5A8HpDYo3RBMP4b8zG88BeueLpwBgrx2Ny1s2kcGPIyb78sSIuQYB8bKXLZn4OotY%2FaqWm6YquRrYFHYp0%2BNONcS5kpaXUwjZPOvgY6pwEmq4nuGf4HOofccyp3zY%2B3CewnwGkzkG5YzIjVOmbIyZF5%2F9MRwR8ZKt8z1BaPndx5q7UL5vFqEEPUVLfCzH7LQI%2F95%2Fm%2BSUV5VSgqDgkJQI273EvHkfrZNBDRd6CHKj3AAigODmGJhpcWMoOakjiY1kYy3kJadbjjYYvcqJQ6nadauCeWPk3OxkyrKLBhmyINba%2F7gG2GVzG%2FWg55SNS6kbv0UNoTuw%3D%3D&Expires=1742521384)

    *This is an automated message from the GitHub Issue Processor.*