npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-api-endpoint-deployment

v0.1.3

Published

Deploy lambda function and perform API related operations

Downloads

23

Readme

AWS API endpoint deployment tool

NPM version NPM downloads

Overview

This tool helps to deploy an API endpoint provisioned as an AWS Lambda Function. It could simply update the lambda code (via zip file or docker), but also could perform other API related operations:

  • Create or update a Lambda alias;
  • Create an API Gateway stage with custom stage variables;
  • Create an API Key and corresponding usage plan.

Note that the corresponding infrastructure (Lambda Function and optionally the API Gateway) must be already provisioned.

Getting Started

How to install

Make sure NodeJS is installed, then run the following command:

$ npm i -g aws-api-endpoint-deployment

How to use

Update Lambda code using a zip file

$ aws-api-endpoint-deployment deploy --r eu-west-1 -l lambdaName -z ./code.zip

Update Lambda code using a zip file through S3

$ aws-api-endpoint-deployment deploy --r eu-west-1 -l lambdaName -z ./code.zip --s3Bucket bucketName --s3Key bucketLey

Update Lambda code using Dockerfile through ECR

$ aws-api-endpoint-deployment deploy --r eu-west-1 -l lambdaName -d ./Dockerfile --imageName lambdaImage

You can also use the parameter --imageVersion to tag the docker image in ECR, by default only latest tag is published.

Deploy entire API environment

$ aws-api-endpoint-deployment deploy 
    --r eu-west-1 
    --lambdaFunctionName lambdaName 
    --lambdaCodeZip ./code.zip 
    --s3Bucket bucketName 
    --s3Key bucketLey
    --lambdaAlias DEV
    --lambdaAliasDesc v1.0.0
    --apiGatewayName apiName
    --apiGatewayStage DEV
    --apiStageVar lambdaAlias=DEV
    --apiKeyName DEV-API-Key
    --apiUsagePlan refPlan

This command assumes that there is an API Gateway already provisioned which invokes the corresponding lambda using the stage variable lambdaAlias as alias, and a default usage plan refPlan also exists to be used as reference to create the new one.

After run this command an isolated environment named DEV is deployed, meaning that there will be a dedicated API Stage with its own API Key for access. This API stage will call the deployed lambda version tagged with the corresponding alias.

This setup is quite useful for CI/CD pipelines which requires an isolated environment to be used by automatic tests for instance. The command output will contain the corresponding API Stage URL and API key, so the pipeline could be fully automatic even for feature branches.

In order to revert the changes on AWS account made by this command, just run the command destroy with the same arguments.

Usage help

Usage: aws-api-endpoint-deployment <command> [options]

Commands:
  aws-api-endpoint-deployment deploy   Deploy API endpoint
  aws-api-endpoint-deployment destroy  Destroy API endpoint
  aws-api-endpoint-deployment prepare  Show the current state of infrastructure

Options:
  -v, --version              Show version number  [boolean]
      --verbose              Enable verbose logging  [boolean]
  -r, --region               AWS region. (AWS_REGION environment variable could be used instead)  [string]
  -l, --lambdaFunctionName   Lambda function name  [string] [required]
  -z, --lambdaCodeZip        Lambda code ZIP file.  [string] [default: "./build/lambda.zip"]
      --s3Bucket             S3 Bucket used to publish lambda code. Only used when --lambdaCodeZip is defined.  [string]
      --s3Key                S3 Key used to publish lambda code. Only used when --lambdaCodeZip is defined.  [string]
  -d, --imageDockerfilePath  Path to the Dockerfile. When set, docker update is used instead of zip file.  [string]
      --imageName            Docker image name. Only used when --imageDockerfilePath is defined.  [string]
      --imageVersion         Docker image version, only "latest" is pushed by default. Only used when --imageDockerfilePath is defined.  [string]
  -a, --lambdaAlias          Lambda alias name to be created or updated if already exists.  [string]
      --lambdaAliasDesc      Lambda alias description.  [string]
      --apiGatewayName       API Gateway name, use to configure API stage.  [string]
      --apiGatewayStage      API Gateway stage name to be created (if does not exist yet).  [string]
      --apiStageVar          Aditional API Gateway stage variables to include on stage creation. Eg. --apiStageVar Var1=val1 --apiStageVar Var2=val2  [array] [default: []]
      --apiKeyName           API Key name to get or create if does't exist. Option --apiUsagePlan must be passed if key does not exist yet.  [string]
      --apiUsagePlan         API Usage Plan name. To be used as reference throttling and quota values when creating the new Usage Plan. Options --apiGatewayName, --apiGatewayStage and --apiKeyName must be defined too.  [string]
  -h, --help                 Show help  [boolean]