https://serverless-stack.com/ logo
#help
Title
# help
d

Dan Van Brunt

11/05/2021, 12:26 AM
Is there a way to setup an EventBridge eventPattern for something like this…
Copy code
event: {
  'detail-type': 'MediaConvert Job State Change',
  source: 'aws.mediaconvert',
  detail: {
    status: 'COMPLETE',
    userMetadata: {
      stackname: 'dev-idx-idx',
    },
  },
}
Right now i have this working…
Copy code
{
  "detail-type": [
    "MediaConvert Job State Change"
  ],
  "source": [
    "aws.mediaconvert"
  ],
  "detail": {
    "status": [
      "COMPLETE"
    ]
  }
}
but I also want to filter on that 
userMetadata.stackname === 'dev-idx-idx'
t

thdxr

11/05/2021, 12:29 AM
does specifying it not work?
idk how deeply nested you can specify detail filters
d

Dan Van Brunt

11/05/2021, 1:16 AM
Ya thats my thoughts…I keep getting invalid pattern when I try different things around the same goal.
How else can I listen for an AWS event and be sure that its one my app created vs another app? This specific event is a MediaConvert COMPLETE event. The only way I know how to know it was MY app that created the Job that created the complete event is to add metaData to the job. But if I can’t filter on it, are there other options?
s

Sione

11/05/2021, 1:55 AM
You can filter on nested object within ‘detail’. Don't know how deep but it has work three level nested filters for me. Values just need to be wrap in an array like: event: { 'detail-type':[ 'MediaConvert Job State’ Change'], source: ['aws.mediaconvert'], detail: { status: ['COMPLETE'], userMetadata: { stackname: ['dev-idx-idx'], }, }, }
d

Dan Van Brunt

11/05/2021, 1:56 AM
@Sione ya that seems right… but I’m still struggling with it.
s

Sione

11/05/2021, 1:58 AM
Ya it's been trial and error for me to get it right. Usually if it is not valid for me it's because I forgot to wrap the all the values I want to filter on in an array.
d

Dan Van Brunt

11/05/2021, 1:59 AM
weird… I even got rid of the userMetadata piece and that console tester is still failing for me 😛
it seems I do not understand how the console tester works 😛
t

thdxr

11/05/2021, 2:01 AM
That error makes it seem like your input event isn't right
s

Sione

11/05/2021, 2:03 AM
Oh is this event to be sent by you or aws ? I don't remember exactly but I don't think they let you creat custom events with source that belong to aws like aws.*. I might be remembering it wrong.
o

Omi Chowdhury

11/05/2021, 2:39 AM
You need to include some required fields in the event (and also remember to hit save after updating the pattern
Pattern:
Copy code
{
  "detail-type": [
    "MediaConvert Job State Change"
  ],
  "source": [
    "aws.mediaconvert"
  ],
  "detail": {
    "status": [
      "COMPLETE"
    ],
    "userMetadata": {
      "stackname": [
        "dev-idx-idx"
      ]
    }
  }
}
Event:
Copy code
{
  "id": "someid",
  "detail-type": "MediaConvert Job State Change",
  "source": "aws.mediaconvert",
  "account": "123456789012",
  "time": "2016-01-10T01:29:23Z",
  "region": "us-east-1",
  "detail": {
    "status": "COMPLETE",
    "userMetadata": {
      "stackname": "dev-idx-idx"
    }
  }
}
d

Dan Van Brunt

11/05/2021, 2:49 AM
Thanks @Omi Chowdhury def was that and also I think there a some bugs in that tester that cause invalid to pop up even when its valid 😄
o

Omi Chowdhury

11/05/2021, 2:50 AM
yeah once an error pops up it doesn’t go away even when its been fixed