šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@henrist/cdk-lambda-config

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@henrist/cdk-lambda-config

CDK Construct for adding config.json file to a Lambda Function

2.1.58
latest
Source
npm
Version published
Maintainers
1
Created
Source

CDK Construct for adding config.json file to a Lambda Function

When using Lambda@Edge, a function cannot use environment variables. This CDK Construct uses a Custom Resource to inject a config.json file with user provided values into an existing function, and publishes a new version that is ready to be used as part of a CloudFront Distribution.

Inspired by similar mechanism in https://github.com/aws-samples/cloudfront-authorization-at-edge/

Usage

npm install @henrist/cdk-lambda-config

Using the construct:

const originalFunction = lambda.Function.fromFunctionArn(...)
const updatedFunction = new LambdaConfig(this, "UpdatedFunction", {
  function: originalFunction,
  config: {
    Key1: "Some value",
    Nested: {
      Key2: "Other value",
    },
  },
  nonce: "1", // See TSDoc.
}
// Can now retrieve the new version:
updatedFunction.version

Read from within the handler:

const fs = require("fs")
const path = require("path")
const config = JSON.parse(
  fs.readFileSync(path.join(__dirname, "config.json"), "utf-8"),
)

Keywords

cdk

FAQs

Package last updated on 24 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts