Removes [yaml](https://github.com/eemeli/yaml). It's no longer used after updating ancestor dependency [aws-cdk-lib](https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib). These dependencies need to be updated together. Removes `yaml` Updates `aws-cdk-lib` from 2.241.0 to 2.248.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/aws/aws-cdk/releases">aws-cdk-lib's releases</a>.</em></p> <blockquote> <h2>v2.248.0</h2> <h3>Bug Fixes</h3> <ul> <li><strong>eks:</strong> downgrade isolated subnet validation from error to warning (<a href="https://redirect.github.com/aws/aws-cdk/issues/37500">#37500</a>) (<a href="https://github.com/aws/aws-cdk/commit/470856cadcee34b2ec5e0620fab63838c223fd97">470856c</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/37491">#37491</a></li> </ul> <hr /> <h2>Alpha modules (2.248.0-alpha.0)</h2> <h2>v2.247.0</h2> <h3>⚠ BREAKING CHANGES</h3> <ul> <li>** L1 resources are automatically generated from public CloudFormation Resource Schemas. They are built to closely reflect the real state of CloudFormation. Sometimes these updates can contain changes that are incompatible with previous types, but more accurately reflect reality. In this release we have changed:</li> </ul> <p>aws-bedrockagentcore: AWS::BedrockAgentCore::OnlineEvaluationConfig: ExecutionStatus attribute removed. aws-appstream: AWS::AppStream::ImageBuilder: Name property is now immutable. aws-eks: AWS::EKS::Capability: EKS_CAPABILITY_ACK_S3_LOGS vended log type removed.</p> <h3>Features</h3> <ul> <li>update L1 CloudFormation resource definitions (<a href="https://redirect.github.com/aws/aws-cdk/issues/37410">#37410</a>) (<a href="https://github.com/aws/aws-cdk/commit/bd2c3187323c7bcf8a19943f86682c14c601d1a9">bd2c318</a>)</li> <li><strong>apigatewayv2:</strong> add role support for lambda authorizers (<a href="https://redirect.github.com/aws/aws-cdk/issues/35706">#35706</a>) (<a href="https://github.com/aws/aws-cdk/commit/2fb2f1650e957979e5ebf8292df3a95d41baa4ff">2fb2f16</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/35696">#35696</a></li> <li><strong>batch:</strong> skip unregister job definition on update (<a href="https://redirect.github.com/aws/aws-cdk/issues/36011">#36011</a>) (<a href="https://github.com/aws/aws-cdk/commit/2fb2240d2b2ca922e0603c3e341bb61ce9131155">2fb2240</a>)</li> <li><strong>elasticloadbalancingv2:</strong> jwt verification for application load balancer (<a href="https://redirect.github.com/aws/aws-cdk/issues/36099">#36099</a>) (<a href="https://github.com/aws/aws-cdk/commit/aacd28aac59dbf42973302e3165140d944356b32">aacd28a</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/36096">#36096</a></li> </ul> <h3>Bug Fixes</h3> <ul> <li>bump brace-expansion from 5.0.3 to 5.0.5 to address CVE-2026-33750 (<a href="https://redirect.github.com/aws/aws-cdk/issues/37379">#37379</a>) (<a href="https://github.com/aws/aws-cdk/commit/69cf4c9c44c610eb029d92e355efcf6e7f931ed2">69cf4c9</a>)</li> <li>prevent prototype pollution in 2 APIs (<a href="https://redirect.github.com/aws/aws-cdk/issues/37453">#37453</a>) (<a href="https://github.com/aws/aws-cdk/commit/101653766cab8a8112608e170f5e07f5b962ba49">1016537</a>)</li> <li><strong>aws-cdk-lib:</strong> condensed stack trace hides namespaced package name (<a href="https://redirect.github.com/aws/aws-cdk/issues/37413">#37413</a>) (<a href="https://github.com/aws/aws-cdk/commit/cb8e7fbc9fc10682d505b2cdba1a7ce173b0dfd3">cb8e7fb</a>)</li> </ul> <hr /> <h2>Alpha modules (2.247.0-alpha.0)</h2> <h3>Features</h3> <ul> <li><strong>mediapackagev2-alpha:</strong> new L2 construct (<a href="https://redirect.github.com/aws/aws-cdk/issues/37279">#37279</a>) (<a href="https://github.com/aws/aws-cdk/commit/7debfb9c5e807fac5df6e9e0ea3097d72325ffbc">7debfb9</a>)</li> </ul> <h2>v2.246.0</h2> <h3>Features</h3> <ul> <li><strong>bedrock:</strong> add MiniMax and GLM foundation model identifiers (<a href="https://redirect.github.com/aws/aws-cdk/issues/37348">#37348</a>) (<a href="https://github.com/aws/aws-cdk/commit/201534444ac183959119c1849f34931fa8f3d18d">2015344</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/37347">#37347</a></li> </ul> <h3>Bug Fixes</h3> <ul> <li><strong>dynamodb:</strong> throw error when grantee is an unsupported ServicePrincipal (<a href="https://redirect.github.com/aws/aws-cdk/issues/37335">#37335</a>) (<a href="https://github.com/aws/aws-cdk/commit/d12754fdeda48181b235cbf563358ffeaa1e4c2f">d12754f</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/35817">#35817</a> <a href="https://redirect.github.com/aws//redirect.github.com/aws/aws-cdk/issues/37273/issues/issuecomment-4099645443">aws/aws-cdk#37273</a></li> <li><strong>lambda-nodejs:</strong> use powershell for spawn steps on Windows (<a href="https://redirect.github.com/aws/aws-cdk/issues/37412">#37412</a>) (<a href="https://github.com/aws/aws-cdk/commit/a92105c64c4ff30bd85f506ef4f7dec39a923871">a92105c</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/37387">#37387</a></li> <li><strong>core:</strong> noisy property deprecation warnings (<a href="https://redirect.github.com/aws/aws-cdk/pull/37415">#37415</a>) (<a href="https://github.com/aws/aws-cdk/commit/4fd000271d26a3dd9f1617800d07e02b40af7db1">4fd0002</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/37407">#37407</a></li> </ul> <h3>Reverts</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/aws/aws-cdk/blob/main/CHANGELOG.v2.alpha.md">aws-cdk-lib's changelog</a>.</em></p> <blockquote> <h1>Changelog</h1> <p>All notable changes to this project will be documented in this file. See <a href="https://github.com/conventional-changelog/standard-version">standard-version</a> for commit guidelines.</p> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.247.0-alpha.0...v2.248.0-alpha.0">2.248.0-alpha.0</a> (2026-04-02)</h2> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.246.0-alpha.0...v2.247.0-alpha.0">2.247.0-alpha.0</a> (2026-04-02)</h2> <h3>Features</h3> <ul> <li><strong>mediapackagev2-alpha:</strong> new L2 construct (<a href="https://redirect.github.com/aws/aws-cdk/issues/37279">#37279</a>) (<a href="https://github.com/aws/aws-cdk/commit/7debfb9c5e807fac5df6e9e0ea3097d72325ffbc">7debfb9</a>)</li> </ul> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.245.0-alpha.0...v2.246.0-alpha.0">2.246.0-alpha.0</a> (2026-03-31)</h2> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.244.0-alpha.0...v2.245.0-alpha.0">2.245.0-alpha.0</a> (2026-03-27)</h2> <h3>Features</h3> <ul> <li><strong>s3tables-alpha:</strong> add support for partition spec, sort order, and table properties (<a href="https://redirect.github.com/aws/aws-cdk/issues/36811">#36811</a>) (<a href="https://github.com/aws/aws-cdk/commit/2696cd16e8e2edc8d40f1443b9c87eb6171e5d1f">2696cd1</a>)</li> <li><strong>s3tables-alpha:</strong> add metrics configuration support for TableBucket (<a href="https://redirect.github.com/aws/aws-cdk/issues/37275">#37275</a>) (<a href="https://github.com/aws/aws-cdk/commit/e8786f5d782d906971f933a2d6d432309d5384d7">e8786f5</a>)</li> <li><strong>s3tables-alpha:</strong> implement ITaggableV2 on TableBucket and Table L2 constructs (<a href="https://redirect.github.com/aws/aws-cdk/issues/37277">#37277</a>) (<a href="https://github.com/aws/aws-cdk/commit/69c8944ea3f4abf0f4218af2fc42c8e862e8cad3">69c8944</a>), closes <a href="https://redirect.github.com/aws/aws-cdk/issues/33054">#33054</a></li> </ul> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.243.0-alpha.0...v2.244.0-alpha.0">2.244.0-alpha.0</a> (2026-03-19)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>kinesisanalytics-flink-alpha:</strong> mark deprecated flink runtimes as deprecated (<a href="https://redirect.github.com/aws/aws-cdk/issues/37155">#37155</a>) (<a href="https://github.com/aws/aws-cdk/commit/0a894472650bb1a2c41050ae2b00581fb937c924">0a89447</a>)</li> </ul> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.242.0-alpha.0...v2.243.0-alpha.0">2.243.0-alpha.0</a> (2026-03-11)</h2> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.241.0-alpha.0...v2.242.0-alpha.0">2.242.0-alpha.0</a> (2026-03-10)</h2> <h3>Features</h3> <ul> <li><strong>mixins-preview:</strong> allow passing resource objects into properties in CFN Property mixins (<a href="https://redirect.github.com/aws/aws-cdk/issues/37148">#37148</a>) (<a href="https://github.com/aws/aws-cdk/commit/f2386291a50961660135b6d13b576a3744fa5ecf">f238629</a>)</li> <li><strong>mixins-preview:</strong> generate EventBridge pattern for all events (<a href="https://redirect.github.com/aws/aws-cdk/issues/37081">#37081</a>) (<a href="https://github.com/aws/aws-cdk/commit/f30e8360112c724ce386f26d7d2bf10d6a58e479">f30e836</a>)</li> <li><strong>mixins-preview:</strong> support custom merge strategies via IMergeStrategy (<a href="https://redirect.github.com/aws/aws-cdk/issues/37170">#37170</a>) (<a href="https://github.com/aws/aws-cdk/commit/0dec0113c45f5808e2afd45ac5be1d044e577a4b">0dec011</a>)</li> </ul> <h2><a href="https://github.com/aws/aws-cdk/compare/v2.240.0-alpha.0...v2.241.0-alpha.0">2.241.0-alpha.0</a> (2026-03-02)</h2> <h3>Features</h3> <ul> <li><strong>mixins-preview:</strong> add <code>recordFields</code> and <code>outputFormat</code> to Vended Logs Mixin (<a href="https://redirect.github.com/aws/aws-cdk/issues/37042">#37042</a>) (<a href="https://github.com/aws/aws-cdk/commit/dd94c312ae77cd9b51cbf6d544c85a2af6a7cdc8">dd94c31</a>)</li> <li><strong>mixins-preview:</strong> cross account delivery destinations (<a href="https://redirect.github.com/aws/aws-cdk/issues/36827">#36827</a>) (<a href="https://github.com/aws/aws-cdk/commit/a759eb69d560ff039d09d62e91627bb267a664e5">a759eb6</a>)</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/aws/aws-cdk/commit/78536e699d4c5acac876156ea0c2aaab7dff3f82"><code>78536e6</code></a> Merge branch 'main' into merge-back/2.247.0</li> <li><a href="https://github.com/aws/aws-cdk/commit/470856cadcee34b2ec5e0620fab63838c223fd97"><code>470856c</code></a> fix(eks): downgrade isolated subnet validation from error to warning (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/37500">#37500</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/7b6c66ff5b92e4071d41defc46558e0c73c887d8"><code>7b6c66f</code></a> chore: update analytics metadata blueprints</li> <li><a href="https://github.com/aws/aws-cdk/commit/6fc7add92e3355556777cd088487259325acaf6f"><code>6fc7add</code></a> chore: yarn upgrade dependencies requiring intervention (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/36806">#36806</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/bd2c3187323c7bcf8a19943f86682c14c601d1a9"><code>bd2c318</code></a> feat: update L1 CloudFormation resource definitions (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/37410">#37410</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/2fb2f1650e957979e5ebf8292df3a95d41baa4ff"><code>2fb2f16</code></a> feat(apigatewayv2): add role support for lambda authorizers (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/35706">#35706</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/aacd28aac59dbf42973302e3165140d944356b32"><code>aacd28a</code></a> feat(elasticloadbalancingv2): jwt verification for application load balancer ...</li> <li><a href="https://github.com/aws/aws-cdk/commit/101653766cab8a8112608e170f5e07f5b962ba49"><code>1016537</code></a> fix: prevent prototype pollution in 2 APIs (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/37453">#37453</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/2fb2240d2b2ca922e0603c3e341bb61ce9131155"><code>2fb2240</code></a> feat(batch): skip unregister job definition on update (<a href="https://github.com/aws/aws-cdk/tree/HEAD/packages/aws-cdk-lib/issues/36011">#36011</a>)</li> <li><a href="https://github.com/aws/aws-cdk/commit/372571a41a93694a3f48046f22508353df323ce3"><code>372571a</code></a> Merge branch 'main' into merge-back/2.246.0</li> <li>Additional commits viewable in <a href="https://github.com/aws/aws-cdk/commits/v2.248.0/packages/aws-cdk-lib">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/awslabs/swift-aws-lambda-runtime/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This directory contains example code for Lambda functions.
Pre-requisites
-
Ensure you have the Swift 6.x toolchain installed. You can install Swift toolchains from Swift.org
-
When developing on macOS, be sure you use macOS 15 (Sequoia) or a more recent macOS version.
-
To build and archive your Lambda functions, you need to install docker.
-
To deploy your Lambda functions and invoke them, you must have an AWS account and install and configure the
awscommand line. -
Some examples are using AWS SAM. Install the SAM CLI before deploying these examples.
-
Some examples are using the AWS CDK. Install the CDK CLI before deploying these examples.
Examples
-
API Gateway V1: an REST API with Amazon API Gateway and a Lambda function as backend (requires AWS SAM).
-
API Gateway V2: an HTTPS API with Amazon API Gateway and a Lambda function as backend (requires AWS SAM).
-
API Gateway V2 with Lambda Authorizer: an HTTPS API with Amazon API Gateway protected by a Lambda authorizer (requires AWS SAM).
-
BackgroundTasks: a Lambda function that continues to run background tasks after having sent the response (requires AWS CLI).
-
CDK: a simple example of an AWS Lambda function invoked through an Amazon API Gateway and deployed with the Cloud Development Kit (CDK).
-
HelloJSON: a Lambda function that accepts JSON as an input parameter and responds with a JSON output (requires AWS CLI).
-
HelloWorld: a simple Lambda function (requires AWS CLI).
-
Hummingbird: a Lambda function using the Hummingbird web framework with API Gateway integration (requires AWS SAM).
-
S3EventNotifier: a Lambda function that receives object-upload notifications from an Amazon S3 bucket.
-
S3_AWSSDK: a Lambda function that uses the AWS SDK for Swift to invoke an Amazon S3 API (requires AWS SAM).
-
S3_Soto: a Lambda function that uses Soto to invoke an Amazon S3 API (requires AWS SAM).
-
Streaming with APIGateway: create a Lambda function exposed by a REST API Gateway. The Lambda function streams its response over time. (requires AWS SAM).
-
Streaming with Function Url: create a Lambda function exposed as an URL. The Lambda function streams its response over time. (requires AWS SAM).
-
Streaming+Codable: a Lambda function that combines JSON input decoding with response streaming capabilities, demonstrating a streaming codable interface (requires AWS SAM or the AWS CLI).
-
Testing: a test suite for Lambda functions.
AWS Credentials and Signature
This section is a short tutorial on the AWS Signature protocol and the AWS credentials.
What is AWS SigV4?
AWS SigV4, short for "Signature Version 4," is a protocol AWS uses to authenticate and secure requests. When you, as a developer, send a request to an AWS service, AWS SigV4 makes sure the request is verified and hasn’t been tampered with. This is done through a digital signature, which is created by combining your request details with your secret AWS credentials. This signature tells AWS that the request is genuine and is coming from a user who has the right permissions.
How to Obtain AWS Access Keys and Session Tokens
To start making authenticated requests with AWS SigV4, you’ll need three main pieces of information:
-
Access Key ID: This is a unique identifier for your AWS account, IAM (Identity and Access Management) user, or federated user.
-
Secret Access Key: This is a secret code that only you and AWS know. It works together with your access key ID to sign requests.
-
Session Token (Optional): If you're using temporary security credentials, AWS will also provide a session token. This is usually required if you're using temporary access (e.g., through AWS STS, which provides short-lived, temporary credentials, or for federated users).
To obtain these keys, you need an AWS account:
-
Sign up or Log in to AWS Console: Go to the AWS Management Console, log in, or create an AWS account if you don’t have one.
-
Create IAM User: In the console, go to IAM (Identity and Access Management) and create a new user. Ensure you set permissions that match what the user will need for your application (e.g., permissions to access specific AWS services, such as AWS Lambda).
-
Generate Access Key and Secret Access Key: In the IAM user credentials section, find the option to generate an "Access Key" and "Secret Access Key." Save these securely! You’ll need them to authenticate your requests.
-
(Optional) Generate Temporary Security Credentials: If you’re using temporary credentials (which are more secure for short-term access), use AWS Security Token Service (STS). You can call the
GetSessionTokenorAssumeRoleAPI to generate temporary credentials, including a session token.
With these in hand, you can use AWS SigV4 to securely sign your requests and interact with AWS services from your Swift app.
⚠️ Security and Reliability Notice
These are example applications for demonstration purposes. When deploying such infrastructure in production environments, we strongly encourage you to follow these best practices for improved security and resiliency:
- Enable access logging on API Gateway (documentation)
- Ensure that AWS Lambda function is configured for function-level concurrent execution limit (concurrency documentation, configuration guide)
- Check encryption settings for Lambda environment variables (documentation)
- Ensure that AWS Lambda function is configured for a Dead Letter Queue (DLQ) (documentation)
- Ensure that AWS Lambda function is configured inside a VPC when it needs to access private resources (documentation, code example)