Skip to content

aws-events: Cannot grant putEvents to Service Principals #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moelasmar opened this issue Mar 14, 2025 · 2 comments
Closed

aws-events: Cannot grant putEvents to Service Principals #2

moelasmar opened this issue Mar 14, 2025 · 2 comments

Comments

@moelasmar
Copy link
Owner

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
Copy link
Owner Author

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

@moelasmar
Copy link
Owner Author

    ## 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%232.txt?AWSAccessKeyId=ASIAQUFLP7FH4X7YJTSX&Signature=JnnfJSBtxjSEUmGLUh4eNruEVFo%3D&x-amz-security-token=IQoJb3JpZ2luX2VjEJr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQCvLxrNmVDyhIgzeWGsyiB4eI7i847ua1ofLUtv1SHDIgIgI6mZJTCAY3ai7%2FofKxxLudlfDGP325zcxU9JyMVVLXEq5AQI4%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwwNDMzMDkzMzI4MTUiDJSkBUQAW%2FOTdPYhdSq4BNY5mNw5WkAYrugZCyA3Mn3UisHxnimv4Su7zR7yPAA6qRSr%2FtKJHaB%2Fus9v%2Bjm3C7zFZN6ncemEn1icqI4hKpdmpAJTTAtkYtwZAMbo6ox3jfOSvtUe%2F4kF%2BUhrMszTYlW5%2Fgc6LQPxN9ciYWLxcg9eYZSeLEMQct6jRLi9KWr6GZt1DhCvbcILMSoPZfueqJK6PShzE6x8E0DPRZMYUYWqSPfGzXycXVEZkfo9GAjsDp4Rlf7%2F8p2uVpUSCoCguLLF9XKJapIdYmlQPG6xmwoEquhTilmZRYX1h9hUiQmUPu%2F0%2FdXg6IMFzW7WQ3vBD4vPg8h3JAAB%2F8lFIBk1%2F%2BuxIUEqMpAktUuP3%2FEzUKbUEQTheJS9WbjgIk%2BV6N%2BZ0xdxjcSbDY0CUCqii0%2BY9vwHyKBez7dPu3tAMhGgHhwfomVEibBQbKVd7x%2FCr9dPhPeWJKpmHLLbGcnb59fiI3DayVfcpWBCPj9lJn06pGOlTXJw71es5T8rqH15ZttLAepXeeO6XGjBhfYq8KBIl5BhN6TgLBrA7riSKldH27lwV9LJUUV31ibXWWcyLX5J9BpjyIUf5RS%2FxITosmKqM%2Bf9m5yvSCNjXhZOkkvWNEXEgfgNex7LkdANMlUd%2Bd4cycjzfT4HQh6D59JmJPeqdAjZ3ufX827Co6r0JsxFXQkRDVVT%2FjVSItBRtRJjBzKR0urh64p6zE1M5tfsXvpkOL%2BG%2F47iWYxtTNPoVUo2d3YTyEIzfYYRkEQwm5TOvgY6pwE1td2nqCyglGYjH9ucCPPXW9f4zinSUqcyH0xID5OJXZRGmiJCEMGV1SAinX6kdGaxu0m9gVD9PyKCzIZ9vxgAyN33JOfeF%2BYEhL9v7H%2B36mV25YH%2BcevyA%2BaZQG4Izt%2BKdo5fPfOBqnsZkpLGVBrtofzL3C071Eb9lUiiGPd1HE33LY3wy4MY7%2B3g6ORxXkZQ0BEHRdHaBaCsS1eoYxzXW8pe1T42dw%3D%3D&Expires=1742521522)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant