serverless-plugin-utils is a collection of essential utilities designed to augment the Serverless Framework's configuration capabilities. Currently stable at version 0.2.0, it provides a set of helper functions primarily consumed directly within `serverless.yml` files, enhancing the declarative power of serverless configurations. These utilities facilitate common operations such as string manipulation (lowercase, uppercase, capitalize, split, join), conditional logic (ternary, switch statements), and other dynamic value resolutions, which are frequently encountered when defining resources, environment variables, or other service properties. It allows developers to create more dynamic and adaptive Serverless configurations without resorting to external scripting or complex custom logic, streamlining tasks like enforcing S3 bucket naming conventions or dynamic domain construction. The package is typically installed as a development dependency and integrates seamlessly into the Serverless Framework's variable resolution system.
npm install serverless-plugin-utilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `serverless-plugin-utils` into your `serverless.yml` and use its functions to dynamically set environment variables for a Lambda function. It showcases `lower`, `capitalize`, `join`, and `ternary` utilities.
Always pin to an exact version (`~0.2.0` or `0.2.0`) and test thoroughly before upgrading. Review the plugin's GitHub repository for any recent activity or changelogs.
Use the documented Serverless variable syntax within your `serverless.yml` configuration. If you need similar logic in your Lambda code, implement it directly in JavaScript/TypeScript using standard library functions.
Verify that `plugins: - serverless-plugin-utils` is present in your `serverless.yml`. Refer to the plugin's documentation for the exact variable prefix if it deviates from the common `fn:`.
Ensure `serverless-plugin-utils` is listed under the `plugins` section in your `serverless.yml`: ```yaml plugins: - serverless-plugin-utils ``` Also, check the compatibility of the plugin with your Serverless Framework version.
YAML is whitespace-sensitive. Carefully review the indentation and spacing of your `serverless.yml` file, especially around utility function calls and their arguments. Use a YAML linter if available.