anyone know why this has no effect and won’t deplo...
# help
s
anyone know why this has no effect and won’t deploy?
Copy code
new sst.EventBus(this, 'VideoUpdateHandler', {
      defaultFunctionProps: { srcPath },
      rules: {
        processUpdateRule: {
          eventPattern: {
            source: ['aws.mediaconvert'],
            detailType: ['MediaConvert Job State Change'],
            detail: {
              queue: [videoQueue.attrArn],
              status: ['COMPLETE', 'PROGRESSING', 'STATUS_UPDATE', 'ERROR'],
            },
          },
          targets: [`${handlerPrefix}/video-process-update.main`],
        },
      },
    });
rather,
yarn start
won’t deploy the event
I haven’t tried a
yarn deploy
yet
wait.. that created a bus. but not the rule itself
t
There's a dropdown to flip between bus's in the rules page
are you on the right one?
s
ohhh wait
duh
yes, sorry. is there a way to just use the default bus?
t
I made the same mistake and lost 15min last week
s
haha
at least it was only 15 mins!
t
You shouldn't use the default bus for your own events because that's where AWS publishes its events
s
ahh ok. good to know!
is there anything I have to do to make a custom bus work? or it just works? for some reason, my Lambda func isn’t getting fired
man, AWS really needs to come up with a way to get support in sub-accounts in an organization when the primary account already pays. doesn’t make senes to pay $100/mo per dev/sandbox account
t
It should just work, it's possible the event pattern isn't matching
s
I’ll have to contact support. it’s the same pattern as in my primary account (deployed w/ SLS) where it does work
t
Also how come you're paying $100 per dev account?
s
my primary account pays $100/mo for Business support. they won’t help you in your other AWS accounts unless you pay
t
Oh for support
Makes sense
s
yeah. but that’s lame.. why would they suggest using multiple dev accounts, and then require you to pay $100/mo for each one? they need to rethink that.
t
Can you add a rule that's a catch all (just specify account id as the pattern) to verify the event is coming through?
Yeah they should cover all your accounts
s
yeah, good idea..i’ll try that.
so theoretically, if I listen to my whole account, I can just upload a file to S3, for example, and that should fire off my Lambda?
so weird. events aren’t working at all
maybe the event bus doesn’t have permission to invoke the Lambda func. I think SLS handled that automatically
aha. https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-use-resource-based.html#eb-lambda-permissions how do I do this in SST? I wonder why I don’t have this in my SLS deployment, and it works just fine? I’ll try
Copy code
eventBus.attachPermissions([[transcodeVideoFunc, 'grantInvoke']]);
t
You don't need to do that, I have it working without explicitly attaching permissions. SST does it for you
Are you sure you're publishing the event?
s
this is an AWS-emitted event. it’s MediaConvert job updates
t
ohh, I see
s
so does it need to be on the default bus then?
will a custom bus pick up AWS-emitted events?
t
So in that case you do need to use the default bus - sst.EventBus can only help you setup new event buses
yeah
s
ahhh
f
@thdxr just to chime in, u should be able import the
default
bus https://docs.serverless-stack.com/constructs/EventBus#importing-an-existing-eventbus
t
Oh oops didn't know that was possible
s
ahh. and I assume there’s a way to programmatically grab the default bus ARN?
f
of course it is 🤪
t
You can actually get it by name
events.EventBus.fromEventBusName(this, "bus", "default")