Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Applying event filters to AWS Lambda Functions with the AWS CDK

The primary motive for writing this article is to address the common error I repeatedly received while troubleshooting event filters: Invalid filter pattern definition. (Service: AWSLambda; Status Code: 400; Error Code:…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

The primary motive for writing this article is to address the common error I repeatedly received while troubleshooting event filters:




Invalid filter pattern definition. (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException




For my case, the goal was to invoke an AWS Lambda function via a DynamoDB stream.






What are Lambda Event Filters



Lambda event filters allow developers to specify which types of records from a stream or queue are submitted to a Lambda. Event filters are included in event source mapping definitions so that Lambda functions are only invoked when the filter criteria is met.






DynamoDB TTL deletion event filter



My use case involved invoking a lambda function to archive resources when a DynamoDB TTL expiry was met. Fortunately, the DynamoDB documentation has a section that describes how to achieve this.



The required filter criteria is as follows:




{
"Filters": [
{
"Pattern": {
"userIdentity": {
"type": ["Service"],
"principalId": ["dynamodb.amazonaws.com"]
}
}
}
]
}






This filter patterns suggests that only actions submitted by the service principal dynamodb.amazonaws.com should be processed by the receiving consumer. This makes sense because the DynamoDB service deletes expired TTL items on our behalf.






Adding event filters to Lambda Functions with AWS CDK



The following example demonstrates how to add event filters to a Lambda function using the AWS CDK in TypeScript:




import * as path from 'path';

import {
Code,
FilterCriteria,
Function,
Runtime,
StartingPosition
} from 'aws-cdk-lib/aws-lambda';

import { AttributeType, StreamViewType, Table } from 'aws-cdk-lib/aws-dynamodb';

import { DynamoEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';

const table = new Table(this, 'Table', {
partitionKey: {
name: 'id',
type: AttributeType.STRING
},
stream: StreamViewType.NEW_IMAGE
});

const lambda = new Function(this, 'Function', {
runtime: Runtime.NODEJS_20_X,
handler: 'index.handler',
code: Code.fromAsset(path.join(__dirname, 'lambda-handler'))
});

lambda.addEventSource(
new DynamoEventSource(databaseTable, {
startingPosition: StartingPosition.TRIM_HORIZON,
filters: [
FilterCriteria.filter({
userIdentity: {
type: ['Service'],
principalId: ['dynamodb.amazonaws.com']
}
})
]
})
)






The crucial part is the inner filters attribute within the event source definition:




lambda.addEventSource(
new DynamoEventSource(databaseTable, {
startingPosition: StartingPosition.TRIM_HORIZON,
filters: [
FilterCriteria.filter({
userIdentity: {
type: ['Service'],
principalId: ['dynamodb.amazonaws.com']
}
})
]
})
)






It's important to note that the static method of FilterCriteria.filter adds the pattern top-level attribute and marshals the inner JSON on our behalf.



As of April 2024, the filters attribute is available on many supported event sources:



1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Applying event filters to AWS Lambda Functions with the AWS CDK
id: 18835307-afa4-48f5-a4b3-36dc2dbdecfc
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Applying event filters to AWS " ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Applying event filters to AWS Lambda Fun")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Applying event filters to AWS Lambda Fun*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Applying event filters to AWS Lambda Fun"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Applying event filters to AWS Lambda Fun.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Applying event filters to AWS Lambda Functions with the AWS CDK

Thematisch verwandte Begriffe: Applying, event, filters, Lambda · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97648 | A vulnerability was detected in ningzichun student-management-system up …
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag