This awsm provides super simple serverless private NPM registry, with fallback to official npmjs.org registry. It uses S3 for storing packages and metadata. Releases can be uploaded directly to configured S3 bucket and
publish action will automatically pick them up and update the metadata for given package, given that S3 event notifications for lambda are set up.
Please be aware that support for NPM features is currently limited. Current version supports fetching packages only with exact version number, latest or versions with caret.
npm install -g jaws-frameworkand create a new project
jaws project create
Install this module
npm install inbot/awsm-npm-registry --save
Set required ENV variables.
# Set your registry bucket name. Value should be <stage>.registry.<domain>, domain being the value that you entered when you created a new JAWS project or stage. jaws env set <stage> all REGISTRY_BUCKET_NAME <bucket_name> # Set registry bucket region. Region is the same region that you selected when creating the project or new stage. jaws env set <stage> all REGISTRY_BUCKET_REGION <region> # Optional: Disable fallback to npmjs.org registry when package is not found from your registry. Defaults to false. jaws env set <stage> all REGISTRY_FALLBACK_DISABLED true
Tell JAWS to update and deploy CloudFormation stack with additional resources added from
jaws deploy resources <stage> <region>
Deploy your project with
jaws dash. Remember to select all
awsm-npm-registryrelated actions and endpoints.
Notice the API Gateway endpoint URL that is printed out. This will be the base URL of your registry.
Set up S3 event notifications for your
Now you should have a private NPM registry to be used with NPM.
Set up S3 event notifications
S3 event notifications are not currently automatically created due some limitations on awsm CloudFormation templates. You need to configure S3 notifications manually for every stage, but only once.
Check out Enabling Event Notifications on how to enable event notifications for a lambda.
Lambda function that you are looking for is
<stage>-<project_name>-l-lAwsmNpmRegistryPublish-*. Open tab
Event Sources and click
Add event source. Fill in the following values and submit.
Event source: S3 Bucket: <stage>.registry.<domain> Event type: Object created (All) Suffix: .tgz
lAwsmNpmRegistryPublish lambda should receive an event whenever new tarballs are pushed to the S3 bucket.
New packages can be published to registry simply by uploading them to the S3 bucket. Just use
npm pack to create a tarball and then upload it to S3 bucket under path
$ cd npm-package $ npm pack npm-package-0.0.1.tgz $ aws s3 cp ./npm-package-<version>.tgz s3://<stage>-<domain>/<package_name>/ --acl public-read
- set up S3 notifications automatically for lambda via CloudFormation stack
- support for
- better support for semver version queries.
- better error handling for main action.
- figure out ENV variables automatically