Giter Club home page Giter Club logo

cdk-lambda-config's Introduction

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"),
)

cdk-lambda-config's People

Contributors

renovate-bot avatar renovate[bot] avatar henrist avatar stekern avatar

Stargazers

Adrián Mouly avatar

Watchers

 avatar

cdk-lambda-config's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update commitlint monorepo to v17.8.1 (@commitlint/cli, @commitlint/config-conventional)
  • chore(deps): update dependency @types/aws-lambda to v8.10.138
  • chore(deps): update dependency @types/jest to v29.5.12
  • chore(deps): update dependency ts-jest to v29.1.3
  • chore(deps): update dependency ts-loader to v9.5.1
  • chore(deps): update dependency ts-node to v10.9.2
  • fix(deps): update dependency adm-zip to v0.5.12 (adm-zip, @types/adm-zip)
  • chore(deps): update dependency @types/node to v18.19.33
  • chore(deps): update dependency eslint to v8.57.0
  • chore(deps): update dependency jest-cdk-snapshot to v2.2.1
  • fix(deps): update dependency aws-sdk to v2.1628.0
  • fix(deps): update dependency axios to v1.7.2
  • fix(deps): update dependency webpack to v5.91.0
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update commitlint monorepo to v19 (major) (@commitlint/cli, @commitlint/config-conventional)
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency husky to v9
  • chore(deps): lock file maintenance
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yaml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @aws-cdk/assert 2.68.0
  • @commitlint/cli 17.8.0
  • @commitlint/config-conventional 17.8.0
  • @types/adm-zip 0.5.2
  • @types/aws-lambda 8.10.124
  • @types/jest 29.5.5
  • @types/node 18.18.5
  • @typescript-eslint/eslint-plugin 5.62.0
  • @typescript-eslint/parser 5.62.0
  • adm-zip 0.5.10
  • aws-cdk-lib 2.84.0
  • aws-sdk 2.1446.0
  • axios 1.6.0
  • constructs 10.3.0
  • eslint 8.51.0
  • eslint-config-prettier 8.10.0
  • eslint-plugin-prettier 4.2.1
  • husky 8.0.3
  • jest 29.7.0
  • jest-cdk-snapshot 2.0.1
  • prettier 2.8.8
  • rimraf 3.0.2
  • semantic-release 19.0.5
  • ts-jest 29.1.1
  • ts-loader 9.5.0
  • ts-node 10.9.1
  • typescript 4.9.5
  • webpack 5.89.0
  • webpack-cli 4.10.0
  • aws-cdk-lib ^2.0.0
  • constructs ^10.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Failed to decrypt field token. Please re-encrypt and try again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.