moelasmar / CodeQlDemoEcsIssue

Demo for using CodeQl
0 stars 0 forks source link

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

Closed moelasmar closed 1 month ago

moelasmar commented 1 month 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 1 month ago

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

moelasmar commented 1 month 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%234.txt?AWSAccessKeyId=ASIAQUFLP7FHTUHHTGDM&Signature=g5xZ2%2FmVxaYocjuwZkd6wnFwd%2B8%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEJr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQCky4EyS7eJNLmf89A0Qp9q4oj5Z%2BDcaUvodh1mOMK3fgIgH4%2BGreDE2UdI%2BmeTDYen0b1yJhFlYkiFr0rPLnns2WIq5AQI4%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDJlgW6S9uDhaXAyy7iq4BN2CHSSz%2BtVxgg75WFN%2F4mY9qtHkbubb7YUfzpaz5KtWNj867bEQi123ZebP9fvkyO5yJM4hAMpojZqGUlwWI825JOZRZv5gG93pZAvD7Vz%2F2N7RW6noGhia9eDZ2r4d2CcHuAKQ1IXnqH56LTXhucla2nRKMNlMVhpc9FjXh40GHNCyzy22pjpd%2BYz55uy4AcFO3R6N4cnz8cqIqDynW8NgHufNJKFyLxhtqjAbvgVvVs1lfCHl1Hb33Q9Yn3RHUt6tcwQAG0yWgGfPOFRaMEZI5iAlFMIkR2%2FWcamK0DuzExPTezUd6JwCYCxwACb5hMbA1t5eEmAzfqURv2eYlFbs4sqG8Zasva5G4k%2B0O4vxfwEYMVYHe5%2B1ImdkfGXhMqrMy0tdfXlsMBe%2FG%2BcZ8gSFeIYyRMNb1mZm7mtBgf%2FbZse4TLSvCZF6318dpneKps4Ktp9osyZpgTAHA6feSx10Woyukgy4Tt3b9UtrUsh%2BXtu8OiVUSwEr3mR1aHgS3cp9AxiBrox%2F%2BuFO1x2SniuYUti0uZx7KKR%2FUJs62a%2BESnJnaY81UkQMXCS%2BlD8F%2FiEEHMwRbCraZv%2FGlHyCyhcS5YfJQuvSNjRR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