Is there a way to setup an EventBridge eventPatter...
# help
d
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
does specifying it not work?
idk how deeply nested you can specify detail filters
d
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
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
@Sione ya that seems right… but I’m still struggling with it.
s
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
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
That error makes it seem like your input event isn't right
s
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
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
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
yeah once an error pops up it doesn’t go away even when its been fixed