### Install serverless-lift Plugin Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md Install the serverless-lift plugin using npm. This is a prerequisite for using the construct. ```bash serverless plugin install -n serverless-lift ``` -------------------------------- ### Basic Serverless Lift Configuration Source: https://github.com/getlift/lift/blob/master/README.md Example serverless.yml configuration to enable the serverless-lift plugin and define basic constructs like a static website and storage. ```yaml service: my-app provider: name: aws plugins: - serverless-lift functions: # ... constructs: # Include Lift constructs here landing-page: type: static-website path: 'landing/dist' avatars: type: storage ``` -------------------------------- ### Define Storage Construct and Function Source: https://github.com/getlift/lift/blob/master/docs/permissions.md This example shows how a `storage` construct automatically grants permissions to a Lambda function defined in the same `serverless.yml` file. ```yaml # serverless.yml constructs: avatars: type: storage functions: myFunction: # ... ``` -------------------------------- ### Lambda Authorizer Handler Example Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Example implementation of a Lambda authorizer handler function. This function is responsible for validating webhook requests. ```javascript export const main = (event, context, callback) => { callback(null, { "isAuthorized": true, }); } ``` -------------------------------- ### Extend CloudFront Distribution Properties Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Extend the underlying CloudFormation resources for the server-side website construct. This example adds a comment to the CloudFront Distribution. ```yaml constructs: website: type: server-side-website assets: '/css/*': public/css '/js/*': public/js extensions: distribution: Properties: DistributionConfig: Comment: Landing distribution ``` -------------------------------- ### Extend CloudFront Distribution Resource Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Extend the underlying CloudFormation resources for a static website construct. This example adds a `Comment` property to the CloudFront Distribution resource. ```yaml constructs: landing: type: static-website path: public extensions: distribution: Properties: Comment: Landing distribution ``` -------------------------------- ### Extend CloudFormation Resources for Webhooks Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Extend the underlying CloudFormation resources for a webhook construct. This example adds a Name property to the EventBridge Bus. ```yaml constructs: stripe: type: webhook insecure: true path: /stripe extensions: bus: Properties: Name: StripeBus ``` -------------------------------- ### Extend CloudFront Distribution Properties Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Customize the underlying CloudFormation resources for your single-page app. This example adds a 'Comment' property to the CloudFront Distribution resource. ```yaml constructs: landing: type: single-page-app path: public extensions: distribution: Properties: Comment: Landing distribution ``` -------------------------------- ### Configure Simple CORS for Storage Source: https://github.com/getlift/lift/blob/master/docs/storage.md Use this simple form to allow a single origin with default methods (GET, PUT, DELETE) and all headers for browser-based uploads. ```yaml constructs: storage: type: storage cors: "${construct:website.url}" ``` -------------------------------- ### Extend DynamoDB Table with TableClass Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md Specify the `extensions` property on a `database/dynamodb-single-table` construct to add CloudFormation properties. This example sets the `TableClass` for the DynamoDB Table resource. ```yaml constructs: myTable: type: database/dynamodb-single-table extensions: table: Properties: TableClass: STANDARD_INFREQUENT_ACCESS ``` -------------------------------- ### Basic SQS Message Handler in JavaScript Source: https://github.com/getlift/lift/blob/master/docs/queue.md Example of a JavaScript handler function for processing SQS messages. The handler receives an event object containing records. ```javascript exports.handler = async function (event, context) { event.Records.forEach(record => { // `record` contains the message that was pushed to SQS }); } ``` -------------------------------- ### Default Permissions for Queue Access Source: https://github.com/getlift/lift/blob/master/docs/queue.md By default, Lambda functions in the same serverless.yml are granted permission to push messages to the queue. No explicit IAM permissions are needed for this basic setup. ```yaml constructs: my-queue: type: queue # ... functions: myFunction: handler: src/publisher.handler environment: QUEUE_URL: ${construct:my-queue.queueUrl} ``` -------------------------------- ### Extend SQS Queue CloudFormation Resource Source: https://github.com/getlift/lift/blob/master/docs/queue.md Use the `extensions` property on a queue construct to modify the underlying CloudFormation resource. This example adds the `MaximumMessageSize: 1024` property to the SQS Queue resource. ```yaml constructs: my-queue: type: queue worker: handler: src/worker.handler extensions: queue: Properties: MaximumMessageSize: 1024 ``` -------------------------------- ### Extend S3 Bucket Properties in Lift Source: https://github.com/getlift/lift/blob/master/README.md Use the `extensions` property to add or modify CloudFormation properties for underlying resources. This example shows how to set `AccessControl` to `PublicRead` for the S3 bucket generated by the `avatars` storage construct. ```yaml constructs: avatars: type: storage extensions: bucket: Properties: AccessControl: PublicRead ``` -------------------------------- ### Configure Retry Delay and Worker Timeout Source: https://github.com/getlift/lift/blob/master/docs/queue.md Adjust the retry delay for SQS messages by setting the worker function's timeout. The retry delay is automatically calculated as 6 times the worker timeout. This example sets the timeout to 10 seconds, resulting in a 60-second retry delay. ```yaml constructs: my-queue: # ... worker: handler: src/worker.handler # We change the timeout to 10 seconds timeout: 10 # The retry delay on the queue will be 10*6 => 60 seconds ``` -------------------------------- ### Basic Server-Side Website Configuration Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md This configuration sets up a server-side website with a home route and assets served from S3 via CloudFront. The first deployment may take up to 5 minutes. ```yaml service: my-app provider: name: aws functions: home: handler: home.handler events: - httpApi: 'GET /' # ... constructs: website: type: server-side-website assets: '/css/*': public/css '/js/*': public/js plugins: - serverless-lift ``` -------------------------------- ### Deploy Static Website with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a static website construct in serverless.yml. Specify the path to your website's static files. ```yaml constructs: landing: type: static-website path: dist ``` -------------------------------- ### Basic Static Website Configuration Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Configure a static website construct in your serverless.yml. The 'path' option specifies the directory containing your website's files. ```yaml service: my-app provider: name: aws constructs: landing: type: static-website path: public plugins: - serverless-lift ``` -------------------------------- ### Basic Single Page App Configuration Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Configure a single-page app construct in serverless.yml, specifying the path to the public directory. ```yaml service: my-app provider: name: aws constructs: landing: type: single-page-app path: public plugins: - serverless-lift ``` -------------------------------- ### Queue Construct with Publisher Function Source: https://github.com/getlift/lift/blob/master/docs/queue.md Deploy a queue named 'jobs' and a 'publisher' function. The publisher function's environment is configured with the queue URL. ```yaml service: my-app provider: name: aws constructs: jobs: type: queue worker: handler: src/worker.handler functions: publisher: handler: src/publisher.handler environment: QUEUE_URL: ${construct:jobs.queueUrl} plugins: - serverless-lift ``` -------------------------------- ### Deploy Server-Side Website with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a server-side website construct in serverless.yml for applications like Laravel or Symfony. Includes asset mapping for static files. ```yaml constructs: website: type: server-side-website assets: '/css/*': public/css '/js/*': public/js ``` -------------------------------- ### Basic Webhook Configuration Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Configure a basic webhook construct in your serverless.yml file. This sets up an API Gateway endpoint that forwards requests to EventBridge. ```yaml service: my-app provider: name: aws constructs: stripe: type: webhook authorizer: handler: myAuthorizer.main path: /my-webhook-endpoint method: POST plugins: - serverless-lift ``` -------------------------------- ### Deploy Single Page Application with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a single-page application construct in serverless.yml. Specify the path to your application's build output. ```yaml constructs: landing: type: single-page-app path: dist ``` -------------------------------- ### Deploy Static Website Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Deploy your static website using the Serverless Framework. This command uploads files to S3 and invalidates the CloudFront cache. ```bash npm run build serverless deploy ``` -------------------------------- ### Basic Storage Construct Configuration Source: https://github.com/getlift/lift/blob/master/docs/storage.md Deploy a preconfigured S3 bucket by defining a storage construct in your serverless.yml. ```yaml service: my-app provider: name: aws constructs: avatars: type: storage plugins: - serverless-lift ``` -------------------------------- ### Deploy Storage Bucket with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a storage construct in serverless.yml to create a preconfigured S3 bucket for storing files. ```yaml constructs: avatars: type: storage ``` -------------------------------- ### Basic Serverless Configuration Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md A minimal serverless.yml configuration to deploy a single DynamoDB table using the dynamodb-single-table construct. ```yaml service: my-app provider: name: aws constructs: myTable: type: database/dynamodb-single-table plugins: - serverless-lift ``` -------------------------------- ### Custom Domain and Certificate Configuration Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Set up a custom domain for your website by providing the domain name and the ARN of an ACM certificate. Ensure the certificate is registered in us-east-1. ```yaml constructs: website: # ... domain: mywebsite.com # ARN of an ACM certificate for the domain, registered in us-east-1 certificate: arn:aws:acm:us-east-1:123456615250:certificate/0a28e63d-d3a9-4578-9f8b-14347bfe8123 ``` -------------------------------- ### Deploy Webhook with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a webhook construct in serverless.yml to receive notifications from third-party applications. Includes path and authorizer configuration. ```yaml constructs: stripe-webhook: type: webhook path: /my-webhook-endpoint authorizer: handler: myAuthorizer.main ``` -------------------------------- ### Static Assets Routing Configuration Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Define routing for static assets like CSS, images, and favicons using the `assets` section. Specify URL patterns and their corresponding local paths. ```yaml constructs: website: # ... assets: '/assets/*': dist/ '/css/*': dist/css '/images/*': assets/animations '/favicon.ico': public/favicon.ico ``` -------------------------------- ### Manual IAM Permissions for S3 Access Source: https://github.com/getlift/lift/blob/master/docs/permissions.md This demonstrates the equivalent manual IAM configuration for allowing Lambda functions to read and write to an S3 bucket managed by a Lift construct. ```yaml # serverless.yml provider: iam: role: statements: - Effect: Allow Action: ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:ListBucket"] Resource: - ${construct:avatars.bucketArn} - Fn::Join: ['', ['${construct:avatars.bucketArn}', '/*']] ... ``` -------------------------------- ### React App Configuration Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Configure the single-page-app construct for a React application, pointing to the build directory. ```yaml constructs: react: type: single-page-app path: build ``` -------------------------------- ### Lift Queue Construct Commands Source: https://github.com/getlift/lift/blob/master/docs/queue.md These commands are available on queue constructs for managing logs, sending messages, and handling failed messages. ```bash serverless :logs ``` ```bash serverless :send ``` ```bash serverless :failed ``` ```bash serverless :failed:purge ``` ```bash serverless :failed:retry ``` -------------------------------- ### Configure Multiple Domains for Server-Side Website Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Specify multiple domain names for your website. The first domain listed is considered the primary. ```yaml constructs: website: # ... domain: - mywebsite.com - app.mywebsite.com ``` -------------------------------- ### Basic Queue Construct Configuration Source: https://github.com/getlift/lift/blob/master/docs/queue.md Configure a basic SQS queue with a Lambda worker. The worker handler is specified using the 'handler' property. ```yaml service: my-app provider: name: aws constructs: my-queue: type: queue worker: handler: src/worker.handler plugins: - serverless-lift ``` -------------------------------- ### Catch-all Route for Backend Frameworks Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Configures a single Lambda function to handle all incoming HTTP routes using a wildcard ('*') with httpApi events. This is useful when using backend frameworks with their own routing mechanisms. ```yaml # serverless.yml # ... functions: backend: handler: index.handler events: - httpApi: '*' constructs: website: type: server-side-website # ... ``` -------------------------------- ### Configure Webhook HTTP Method Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Specify the HTTP method for the webhook. Defaults to POST. ```yaml constructs: stripe: # ... method: POST ``` -------------------------------- ### Deploy DynamoDB Single Table with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a database construct in serverless.yml to deploy a DynamoDB table using Single Table Design principles. ```yaml constructs: database: type: database/dynamodb-single-table ``` -------------------------------- ### Upload Website Files Directly Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Upload website files and invalidate the CloudFront cache without a full CloudFormation deployment. ```bash serverless landing:upload ``` -------------------------------- ### Deploy SQS Queue and Worker with Lift Source: https://github.com/getlift/lift/blob/master/README.md Configure a queue construct in serverless.yml to deploy an SQS queue and a worker function for asynchronous processing. ```yaml constructs: my-queue: type: queue worker: handler: src/report-generator.handler ``` -------------------------------- ### Serve Custom Error Page for Static Website Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Configure a custom error page for 404 Not Found responses. This is useful for static websites that are not Single-Page Applications. Ensure the specified HTML file exists in your project. ```yaml constructs: landing: # ... errorPage: error.html ``` -------------------------------- ### Configure Webhook Path Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Specify the required `path` for your webhook endpoint. The final URL will be displayed after deployment. ```yaml constructs: stripe: type: webhook path: /my-path ``` -------------------------------- ### Configure Event Type - Static String Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Alternatively, configure `eventType` with a static string. This is less efficient than using a dynamic path selector. ```yaml constructs: stripe: # ... eventType: stripe ``` -------------------------------- ### Defining Multiple Website Routes Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Defines specific Lambda functions for different HTTP routes using httpApi events. Ensure to check the official Serverless Framework documentation for httpApi event configuration. ```yaml # serverless.yml # ... functions: home: handler: home.handler events: - httpApi: 'GET /' search: handler: search.handler events: - httpApi: 'GET /search' # ... constructs: website: type: server-side-website # ... ``` -------------------------------- ### Vue App Configuration Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Configure the single-page-app construct for a Vue application, pointing to the dist directory. ```yaml constructs: vue: type: single-page-app path: dist ``` -------------------------------- ### Upload Website Changes Directly Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Directly upload website changes to S3 and clear the CloudFront cache without a full CloudFormation deployment. This command is faster for updates. ```bash serverless :upload # For example: serverless landing:upload ``` -------------------------------- ### Injecting Table Name to Lambda Environment Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md Demonstrates how to use the `tableName` variable exposed by the construct to set the TABLE_NAME environment variable for a Lambda function. ```yaml constructs: myTable: type: database/dynamodb-single-table functions: myFunction: handler: src/index.handler environment: TABLE_NAME: ${construct:myTable.tableName} ``` -------------------------------- ### Configure Custom Domain for Single Page App Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Configure a custom domain and ACM certificate for the single-page-app construct to serve the website over HTTPS. ```yaml constructs: landing: # ... domain: mywebsite.com # ARN of an ACM certificate for the domain, registered in us-east-1 certificate: arn:aws:acm:us-east-1:123456615250:certificate/0a28e63d-d3a9-4578-9f8b-14347bfe8123 ``` -------------------------------- ### Enable FIFO Queue Source: https://github.com/getlift/lift/blob/master/docs/queue.md Enable SQS FIFO queues for strict message ordering. This configures both the main and dead-letter queues as FIFO. ```yaml constructs: my-queue: # ... fifo: true ``` -------------------------------- ### Configure Full CORS Rules for Storage Source: https://github.com/getlift/lift/blob/master/docs/storage.md The full form allows for complete CORS rule definition, including specific allowed origins, methods, and headers. This maps directly to CloudFormation CorsRules. ```yaml constructs: storage: type: storage cors: - allowedOrigins: - "${construct:website.url}" allowedMethods: - PUT allowedHeaders: - "*" ``` -------------------------------- ### Configure Event Type - Dynamic Path Selector Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Use a dynamic path selector for `eventType` to dynamically determine the event type from the request body. This is the recommended approach for efficiency. ```yaml constructs: stripe: # ... eventType: $request.body.type ``` -------------------------------- ### Redirect Domains to a Main Domain Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Set up automatic redirection from secondary domains to a primary domain. This ensures users always land on the designated main URL, such as redirecting the root domain to its 'www' version. ```yaml constructs: website: # ... domain: - www.mywebsite.com - mywebsite.com redirectToMainDomain: true ``` -------------------------------- ### Configure Authorizer Environment Variables Source: https://github.com/getlift/lift/blob/master/docs/webhook.md You can configure environment variables for your Lambda authorizer function within the webhook construct. Lift automatically configures the function to be triggered by API Gateway. ```yaml constructs: stripe: # ... authorizer: handler: stripe/authorizer.main environment: STRIPE_SECRET: my-secret ``` -------------------------------- ### Enable SQS Queue Encryption with Custom KMS Key Source: https://github.com/getlift/lift/blob/master/docs/queue.md Enable server-side encryption for the SQS queue and specify a custom KMS key for management. ```yaml constructs: my-queue: # ... # Encryption will be enabled and managed by AWS encryption: 'kms' encryptionKey: 'MySuperSecretKey' ``` -------------------------------- ### Configure Lambda Authorizer Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Define a Lambda authorizer function to handle signature verification for incoming webhook requests. The handler should return a simple payload indicating authorization status. ```yaml constructs: stripe: # ... authorizer: handler: stripe/authorizer.main ``` -------------------------------- ### S3 Bucket Policy Configuration Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Use the `assetsBucketName` variable to configure S3 bucket policies, ensuring correct access permissions for your website's assets. ```yaml constructs: website: type: server-side-website # ... resources: Resources: BucketPolicy: Type: AWS::S3::BucketPolicy Properties: Bucket: ${construct:website.assetsBucketName} # ... ``` -------------------------------- ### Configure Multiple Domains for SPA Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Specify multiple domain names for your single-page application. This is useful for hosting your app on various subdomains or custom domains. ```yaml constructs: landing: # ... domain: - mywebsite.com - app.mywebsite.com ``` -------------------------------- ### Publish Message to SQS Queue Source: https://github.com/getlift/lift/blob/master/docs/queue.md Use the AWS SDK to send a message to an SQS queue. The queue URL is retrieved from environment variables. ```javascript // src/publisher.js const AWS = require('aws-sdk'); const sqs = new AWS.SQS({ apiVersion: 'latest', region: process.env.AWS_REGION, }); exports.handler = async function(event, context) { // Send a message into SQS await sqs.sendMessage({ QueueUrl: process.env.QUEUE_URL, // Any message data we want to send MessageBody: JSON.stringify({ fileName: 'foo/bar.mp4' }), }).promise(); } ``` -------------------------------- ### API Gateway Type Configuration Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Configure the API Gateway version for your website. Use `apiGateway: 'rest'` for v1 REST APIs or omit for the default v2 HTTP APIs. ```yaml constructs: website: type: server-side-website apiGateway: 'rest' # either "rest" (v1) or "http" (v2, the default) functions: v1: handler: foo.handler events: - http: 'GET /' # REST API (v1) v2: handler: bar.handler events: - httpApi: 'GET /' # HTTP API (v2) ``` -------------------------------- ### Environment Variable for Website URL Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Use the `url` variable to access the deployed website's URL in environment variables. It automatically resolves to the CloudFront or custom domain URL. ```yaml constructs: website: type: server-side-website # ... functions: backend: # ... environment: WEBSITE_URL: ${construct:website.url} ``` -------------------------------- ### Configure KMS Encryption for Storage Source: https://github.com/getlift/lift/blob/master/docs/storage.md Enable KMS encryption for the S3 bucket by setting the `encryption` property to `kms`. ```yaml constructs: avatars: # ... encryption: kms ``` -------------------------------- ### Define Custom Lifecycle Rules for Storage Source: https://github.com/getlift/lift/blob/master/docs/storage.md Configure custom S3 lifecycle rules for object expiration or transition based on prefixes and days. ```yaml constructs: avatars: type: storage lifecycleRules: - prefix: tmp/ expirationInDays: 1 - prefix: cache/ expirationInDays: 7 ``` -------------------------------- ### Configure Queue Worker with Additional Settings Source: https://github.com/getlift/lift/blob/master/docs/queue.md Configure the queue worker with additional Lambda function settings like memorySize and timeout. Lift automatically configures the SQS trigger. ```yaml constructs: my-queue: # ... worker: handler: src/worker.handler memorySize: 512 timeout: 10 ``` -------------------------------- ### Configure S3 Bucket Policy with Assets Bucket Name Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Use the 'assetsBucketName' variable to reference the S3 bucket managed by the static-website construct in a bucket policy. ```yaml constructs: landing: type: static-website # ... resources: Resources: BucketPolicy: Type: AWS::S3::BucketPolicy Properties: Bucket: ${construct:landing.assetsBucketName} # ... ``` -------------------------------- ### Enable ACL Support for Storage Bucket Source: https://github.com/getlift/lift/blob/master/docs/storage.md Allow the S3 bucket to accept ACL headers by setting `allowAcl` to `true`, which is useful for compatibility with certain libraries. ```yaml constructs: storage: type: storage allowAcl: true ``` -------------------------------- ### Referencing Queue Variables in Serverless Config Source: https://github.com/getlift/lift/blob/master/docs/queue.md Use construct variables like 'queueUrl' to reference SQS queue details in other Lambda functions' environment variables. ```yaml constructs: my-queue: type: queue functions: otherFunction: handler: src/publisher.handler environment: QUEUE_URL: ${construct:my-queue.queueUrl} ``` -------------------------------- ### Configure Email Alerts for Dead Letter Queue Source: https://github.com/getlift/lift/blob/master/docs/queue.md Configure email alerts for messages that end up in the dead letter queue. An email confirmation will be sent after the first deployment. ```yaml constructs: my-queue: # ... alarm: alerting@mycompany.com ``` -------------------------------- ### Enable SQS Queue Encryption with KMS Managed Key Source: https://github.com/getlift/lift/blob/master/docs/queue.md Enable server-side encryption for the SQS queue using an AWS-managed KMS key. ```yaml constructs: my-queue: # ... # Encryption will be enabled and managed by AWS encryption: 'kmsManaged' ``` -------------------------------- ### Enabling Local Secondary Indexes Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md Enables the creation of 5 local secondary indexes (LSIs) on the DynamoDB table. Note that LSIs have limitations on partition size and require table re-creation if modified after data population. ```yaml constructs: myTable: # ... localSecondaryIndexes: true ``` -------------------------------- ### Configure Maximum Batching Window for SQS Source: https://github.com/getlift/lift/blob/master/docs/queue.md Set the maximum time SQS will wait to gather records before invoking the Lambda function. This increases the chance of a full batch but may delay processing. The window can be set between 0 and 300 seconds. ```yaml constructs: my-queue: # ... maxBatchingWindow: 5 # SQS will wait 5 seconds (so that it can batch any messages together) before delivering to lambda ``` -------------------------------- ### Configure Queue Worker Handler Source: https://github.com/getlift/lift/blob/master/docs/queue.md Configure the Lambda function handler for the queue worker. This can be done by referencing an existing function or defining the worker as an object. ```yaml constructs: my-queue: type: queue worker: # The Lambda function is configured here handler: src/worker.handler ``` ```yaml function: my-worker: handler: src/worker.handler constructs: my-queue: type: queue # References the my-worker function defined in the function section worker: my-worker ``` -------------------------------- ### Configure Custom Error Page for Server-Side Website Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Specify a custom HTML file to be displayed when an internal server error occurs. This overrides the default API Gateway error page. ```yaml constructs: website: # ... errorPage: error500.html ``` -------------------------------- ### Reference CloudFront CNAME in Route53 Source: https://github.com/getlift/lift/blob/master/docs/static-website.md Use the 'cname' variable exposed by the static-website construct to create an AliasTarget in Route53 for a custom domain. ```yaml constructs: landing: type: static-website path: public resources: Resources: Route53Record: Type: AWS::Route53::RecordSet Properties: HostedZoneId: ZXXXXXXXXXXXXXXXXXXJ # Your HostedZoneId Name: app.mydomain Type: A AliasTarget: HostedZoneId: Z2FDTNDATAQYW2 # Cloudfront Route53 HostedZoneId. This does not change. DNSName: ${construct:landing.cname} ``` -------------------------------- ### Serverless TypeScript Configuration with Lift Source: https://github.com/getlift/lift/blob/master/docs/serverless-types.md Use this configuration when defining your Serverless service in TypeScript with Lift. It merges the official AWS types with Lift's types to correctly include Lift-specific configurations like `constructs`. ```typescript import type { AWS } from '@serverless/typescript'; import type { Lift } from "serverless-lift"; const serverlessConfiguration: AWS & Lift = { service: 'myService', frameworkVersion: '2', plugins: ['serverless-lift'], lift: { automaticPermissions: false, }, constructs: { avatars: { type: 'storage', }, }, provider: { name: 'aws', runtime: 'nodejs14.x', }, functions: { hello: { handler: 'src/publisher.handler', } } }; module.exports = serverlessConfiguration; ``` -------------------------------- ### Route53 Record for Custom Domain Source: https://github.com/getlift/lift/blob/master/docs/server-side-website.md Configure a Route53 record to point a custom domain to the CloudFront distribution using the `cname` variable. Ensure you use the correct CloudFront Route53 HostedZoneId. ```yaml constructs: website: type: server-side-website # ... resources: Resources: Route53Record: Type: AWS::Route53::RecordSet Properties: HostedZoneId: ZXXXXXXXXXXXXXXXXXXJ # Your HostedZoneId Name: app.mydomain Type: A AliasTarget: HostedZoneId: Z2FDTNDATAQYW2 # Cloudfront Route53 HostedZoneId. This does not change. DNSName: ${construct:website.cname} ``` -------------------------------- ### Configure SQS Batch Size Source: https://github.com/getlift/lift/blob/master/docs/queue.md Set the number of messages Lambda will receive at a time from the SQS queue. The default is 1 message per invocation to simplify error handling. For batch sizes over 10, `maxBatchingWindow` must be set. ```yaml constructs: my-queue: # ... batchSize: 5 # Lambda will receive 5 messages at a time ``` -------------------------------- ### Reference CloudFront CNAME in Route53 Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Use the 'cname' variable to reference the CloudFront distribution's domain name in Route53 AliasTarget. ```yaml constructs: landing: type: single-page-app path: public resources: Resources: Route53Record: Type: AWS::Route53::RecordSet Properties: HostedZoneId: ZXXXXXXXXXXXXXXXXXXJ # Your HostedZoneId Name: app.mydomain Type: A AliasTarget: HostedZoneId: Z2FDTNDATAQYW2 # Cloudfront Route53 HostedZoneId. This does not change. DNSName: ${construct:landing.cname} ``` -------------------------------- ### Disable Authorizer (Insecure) Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Optionally disable the authorizer by setting `insecure: true`. This is not recommended for production environments as it bypasses webhook validation. ```yaml constructs: stripe: # ... insecure: true ``` -------------------------------- ### Handle Partial Batch Failures in Lift Source: https://github.com/getlift/lift/blob/master/docs/queue.md When processing message batches, return this JSON format from your worker function to indicate specific messages that failed, rather than the entire batch. This requires the `itemIdentifier` key for each failed message. ```json { "batchItemFailures": [ { "itemIdentifier": "id2" }, { "itemIdentifier": "id4" } ] } ``` -------------------------------- ### Disable Automatic Permissions for Storage Construct Source: https://github.com/getlift/lift/blob/master/docs/configuration.md Use `automaticPermissions: false` under the `lift` property to disable default IAM permissions for constructs. This allows for more fine-grained control over permissions, especially in production environments. ```yaml service: my-app provider: name: aws lift: automaticPermissions: false constructs: avatars: type: storage plugins: - serverless-lift ``` -------------------------------- ### Allow Embedding in Iframes Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Explicitly permit your single-page application to be embedded within iframes. By default, this is disallowed for security reasons. ```yaml constructs: landing: # ... security: allowIframe: true ``` -------------------------------- ### Configuring Global Secondary Indexes Source: https://github.com/getlift/lift/blob/master/docs/database-dynamodb-single-table.md Specifies the number of global secondary indexes (GSIs) to create on the DynamoDB table. The count can be between 1 and 20. ```yaml constructs: myTable: # ... gsiCount: 3 ``` -------------------------------- ### Reference Bucket Name in Environment Variables Source: https://github.com/getlift/lift/blob/master/docs/storage.md Use the `bucketName` variable to set the S3 bucket name as an environment variable for Lambda functions. ```yaml constructs: avatars: type: storage functions: myFunction: handler: src/index.handler environment: BUCKET_NAME: ${construct:avatars.bucketName} ``` -------------------------------- ### Reference S3 Bucket Name in Bucket Policy Source: https://github.com/getlift/lift/blob/master/docs/single-page-app.md Use the 'assetsBucketName' variable to reference the S3 bucket name when configuring a bucket policy. ```yaml constructs: landing: type: single-page-app # ... resources: Resources: BucketPolicy: Type: AWS::S3::BucketPolicy Properties: Bucket: ${construct:landing.assetsBucketName} # ... ``` -------------------------------- ### Reference EventBridge Bus Name Source: https://github.com/getlift/lift/blob/master/docs/webhook.md Use the `busName` variable to reference the deployed EventBridge bus in your function's event configuration. This allows your consumer function to subscribe to events published by the webhook. ```yaml constructs: stripe: # ... functions: myConsumer: handler: src/stripeConsumer.handler events: - eventBridge: eventBus: ${construct:stripe.busName} pattern: source: # filter all events received on stripe webhook - stripe detail-type: - invoice.paid ``` -------------------------------- ### Configure Maximum Retries for SQS Queue Source: https://github.com/getlift/lift/blob/master/docs/queue.md Set the maximum number of times an SQS message will be retried if Lambda processing fails. Default is 3 retries. Messages failing after max retries are moved to a dead-letter queue. ```yaml constructs: my-queue: # ... maxRetries: 5 ``` -------------------------------- ### Configure Message Delivery Delay Source: https://github.com/getlift/lift/blob/master/docs/queue.md Postpone the delivery of messages to the SQS queue by a specified number of seconds. The maximum delay allowed is 900 seconds (15 minutes). ```yaml constructs: my-queue: # ... # Messages delivery will be delayed by 1 minute delay: 60 ``` -------------------------------- ### Disable Automatic Lift IAM Permissions Source: https://github.com/getlift/lift/blob/master/docs/permissions.md Configure Lift to disable automatic IAM permission generation by setting `automaticPermissions` to `false` in your `serverless.yml`. ```yaml # serverless.yml lift: automaticPermissions: false ``` -------------------------------- ### Disable Content-Based Deduplication for FIFO Queue Source: https://github.com/getlift/lift/blob/master/docs/queue.md Disable content-based deduplication for FIFO queues using a custom extension. This is necessary if you want to use unique deduplication IDs. ```yaml constructs: my-queue: # ... extensions: queue: Properties: ContentBasedDeduplication: false ``` -------------------------------- ### Configure Maximum Concurrency for SQS Event Source Source: https://github.com/getlift/lift/blob/master/docs/queue.md Limit the maximum number of concurrent Lambda function instances that can be invoked by the SQS event source. This setting controls how many messages Lambda reads from the queue, not the function's overall concurrency. ```yaml constructs: my-queue: # ... maxConcurrency: 10 # The maximum number of concurrent function instances that the SQS event source can invoke is 10 ``` -------------------------------- ### Worker Function to Process SQS Messages Source: https://github.com/getlift/lift/blob/master/docs/queue.md Process messages from an SQS queue. The worker function iterates through event records and parses the message body. ```javascript // src/worker.js exports.handler = function(event, context) { // SQS may invoke with multiple messages for (const message of event.Records) { const bodyData = JSON.parse(message.body); const fileName = bodyData.fileName; // do something with `fileName` } } ```