Does anyone know how to attach policies to and Eve...
# help
n
Does anyone know how to attach policies to and EventBus? I see the attachParmissions method, but it appears to attach permissions to targets. I’m trying to do a cross account polilcy and don’t see how i can attach policies to the bus itself…not the targets.
m
Copy code
bus.attachPermissionsToTarget("rule1", 0, [
    s3,
    // Policy granting access to a specific folder in the bucket
    new iam.PolicyStatement({
      actions: ["s3:*"],
      effect: iam.Effect.ALLOW,
      resources: [
        bucket.bucketArn + "/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
      ],
    }),
  ]);
can you try like above @Nathan?
n
It looks like that attaches a policy to a specific rule target. For instance if a rule was targeting a lambda, it would attach the rule to that lambda. How do I attach a policy to the eventbus itself?
f
Hey @Nathan, if u r looking to grant a function the permission to send message to the bus, you can do
Copy code
fn.attachPermissions([bus]);
Is this what you were looking for?
n
I have an eventbus in one aws account. I need it to be able to forward messages to an eventbus in another. From what I’ve seen an eventbus cannot talk to lambdas,cross account. So I was trying to follow these instructions.

https://www.youtube.com/watch?v=pX_xIW_EuCE

I was hoever trying to do this with SST code. I want the eventbus Im creating to have a policy that allows put events from the eventbus in the source account.
the attachPermissions method looks like it only works on targets…not the event bus itself