Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosIntel Devs: Smart AI Edge Solutions - 0 Introduction | Intel Software(22.09.2026 um 23:48 Uhr)
Windows Tipps & SecurityGoogles gibt Chrome 154 frei und schließt über 100 Lücken(23.09.2026 um 09:11 Uhr)
Windows Tipps & SecurityKlangerlebnis & Sicherheit im Vonovia Ruhrstadion(23.09.2026 um 08:45 Uhr)
Unix & Linux ServerLocal AI Jargon Quiz: Do You Know All These Buzzwords?(23.09.2026 um 08:38 Uhr)
Sichere ProgrammierungNeu von AWS: Weniger Kontextpflege für selbst gebaute KI-Agenten(23.09.2026 um 09:52 Uhr)
Sichere ProgrammierungLINQ GroupBy: The Operator Everyone Uses Wrong(23.09.2026 um 09:41 Uhr)
Sichere ProgrammierungIT Heard About the Acquisition Nine Days Before It Closed(23.09.2026 um 09:45 Uhr)
YouTube Security VideosIntel Devs: Smart AI Edge Solutions - 0 Introduction | Intel Software(22.09.2026 um 23:48 Uhr)
Windows Tipps & SecurityGoogles gibt Chrome 154 frei und schließt über 100 Lücken(23.09.2026 um 09:11 Uhr)
Windows Tipps & SecurityKlangerlebnis & Sicherheit im Vonovia Ruhrstadion(23.09.2026 um 08:45 Uhr)
Unix & Linux ServerLocal AI Jargon Quiz: Do You Know All These Buzzwords?(23.09.2026 um 08:38 Uhr)
Sichere ProgrammierungNeu von AWS: Weniger Kontextpflege für selbst gebaute KI-Agenten(23.09.2026 um 09:52 Uhr)
Sichere ProgrammierungLINQ GroupBy: The Operator Everyone Uses Wrong(23.09.2026 um 09:41 Uhr)
Sichere ProgrammierungIT Heard About the Acquisition Nine Days Before It Closed(23.09.2026 um 09:45 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Creating an API Gateway with AWS SAM and Node.js

If you're building a serverless application with Lambda, chances are you need to expose your functions as APIs. That's where Amazon API Gateway comes in — and AWS SAM makes it incredibly easy to define and deploy them. In this post, y…

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

If you're building a serverless application with Lambda, chances are you need to expose your functions as APIs. That's where Amazon API Gateway comes in — and AWS SAM makes it incredibly easy to define and deploy them.



In this post, you’ll learn how to:




  • Define an API Gateway in template.yml

  • Connect it to a Lambda function

  • Understand the difference between REST API and HTTP API in terms of performance and cost









🧱 Step 1: Define the Lambda Function



Here’s a simple function that responds to HTTP requests:




Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs22.x
Events:
HelloWorldApi:
Type: Api
Properties:
Path: /hello
Method: get






This tells SAM to automatically provision an API Gateway and connect it to your Lambda. The Path and Method define the route.






💡 Optional: Define the API Resource Explicitly



To configure advanced settings (like CORS or API type), you can explicitly define an API Gateway:




Globals:
Api:
Name: MyApi
Cors:
AllowMethods: "'GET,POST,OPTIONS'"
AllowHeaders: "'Content-Type'"
AllowOrigin: "'*'"






Or define the resource yourself:




Events:
HelloWorldApi:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /hello
Method: get






Then connect it to your function like this:




Events:
HelloWorldApi:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /hello
Method: get









🧪 Step 2: Write the Handler Code



Here’s your basic index.ts (or index.js):




export const handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: "Hello from Lambda!" }),
};
};












⚔️ REST API vs HTTP API: Which Should You Use?



AWS offers two types of API Gateway APIs:



🚀 HTTP API (Recommended for Most Use Cases)




  • Faster cold starts

  • Lower cost (~70% cheaper than REST API)

  • Supports most common use cases (JWT auth, CORS, etc.)

  • Limited advanced features (e.g., direct VPC integration)



🧱 REST API




  • More mature, full feature set

  • Supports API keys, usage plans, request validation

  • More expensive and slightly higher latency



TL;DR:




  • Use HTTP API for most web or mobile apps

  • Use REST API if you need advanced API Gateway features



To switch to HTTP API in SAM:




Events:
HelloWorldApi:
Type: HttpApi
Properties:
Path: /hello
Method: get












Conclusion



Creating APIs with AWS SAM is incredibly simple — just define an event and SAM handles the rest. Now you can:



✅ Connect Lambda to API Gateway

✅ Choose between REST or HTTP API based on needs

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Creating an API Gateway with AWS SAM and Node.js

Thematisch verwandte Begriffe: Creating, Gateway, with, Nodejs · 6 Treffer

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-96258 | A vulnerability has been found in onSite internet GmbH Auktion NG Auktio…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
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
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick