diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a4acad..002cd23 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,20 @@ jobs: name: Publish layers command: ./publish-layers.sh nodejs8.10 + publish-njs10: + docker: + - image: circleci/node:10-stretch + working_directory: ~/circleci-deployment + steps: + - checkout + - run: sudo apt-get install -y python3-pip + - run: + name: Install publish dependencies + command: sudo pip3 install -U awscli + - run: + name: Publish layers + command: ./publish-layers.sh nodejs10.x + workflows: version: 2 all: @@ -112,3 +126,12 @@ workflows: ignore: /.*/ tags: only: /^v.*/ + - publish-njs10: + requires: + - install + - test + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ diff --git a/README.md b/README.md index d5ada5e..c3c49d1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -IOpipe Agent & Tracing Plugin +IOpipe Agent & Bundled Plugins ----------------------------- [![npm version](https://badge.fury.io/js/%40iopipe%2Fiopipe.svg)](https://badge.fury.io/js/%40iopipe%2Fiopipe) [![Slack](https://img.shields.io/badge/chat-slack-ff69b4.svg)](https://iopipe.now.sh/) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) -This package provides the IOpipe agent and the tracing plugin pre-bundled. +This package provides the IOpipe agent and plugins pre-bundled. # Installation & usage @@ -21,9 +21,9 @@ Or via yarn: yarn add @iopipe/iopipe ``` -Then require this module, passing it an object with your project token ([register for access](https://www.iopipe.com)), and it will automatically monitor and collect metrics from your applications running on AWS Lambda. +Then require this module, passing it an object with your project token ([get a free account](https://www.iopipe.com)), and it will automatically monitor and collect metrics from your applications running on AWS Lambda. -If you are using the Serverless Framework to deploy your lambdas, check out our [serverless plugin](https://github.com/iopipe/serverless-plugin-iopipe). +If you are using the Serverless Framework to deploy your lambdas, check out our [serverless plugin](https://github.com/iopipe/serverless-iopipe-layers). Example: @@ -35,9 +35,12 @@ exports.handler = iopipe((event, context) => { }); ``` -By default this package will enable @iopipe/trace and @iopipe/event-info plugins. For more information on how to use IOpipe and these plugins, see the documentation below: +By default this package will enable `@iopipe/trace` and `@iopipe/event-info` plugins. It also includes the `@iopipe/profiler` plugin, which is disabled by default. For more information on how to use IOpipe and these plugins, see the documentation below: + - [IOpipe Documentation](https://github.com/iopipe/iopipe-js-core#readme) - [IOpipe Tracing Plugin Documentation](https://github.com/iopipe/iopipe-plugin-trace#readme) +- [IOpipe Event Info Plugin Documentation](https://github.com/iopipe/iopipe-plugin-event-info#readme) +- [IOpipe Profiler Plugin Documentation](https://github.com/iopipe/iopipe-plugin-profiler#readme) Example With Tracing, Custom Metrics, and Labels (ES6 Module Format): @@ -65,6 +68,7 @@ exports.handler = iopipe()(async (event, context) => { IOpipe publishes [AWS Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) which are publicly available on AWS. Using a framework that supports lambda layers (such as SAM or Serverless), you can use the following ARNs for your runtime: +* nodejs10.x: `arn:aws:lambda:$REGION:146318645305:layer:IOpipeNodeJS10:$VERSION_NUMBER` * nodejs8.10: `arn:aws:lambda:$REGION:146318645305:layer:IOpipeNodeJS810:$VERSION_NUMBER` * nodejs6.10: `arn:aws:lambda:$REGION:146318645305:layer:IOpipeNodeJS610:$VERSION_NUMBER` diff --git a/latest-layer-arns.sh b/latest-layer-arns.sh index 0af7433..b0e878e 100755 --- a/latest-layer-arns.sh +++ b/latest-layer-arns.sh @@ -18,6 +18,18 @@ REGIONS=( us-west-2 ) +echo "### Lambda Layer ARNs" +echo "" + +echo "nodejs10.x:" +echo "" + +for region in "${REGIONS[@]}"; do + latest_arn=$(aws --region $region lambda list-layer-versions --layer-name IOpipeNodeJS10 --output text --query "LayerVersions[0].LayerVersionArn") + echo "* ${region}: \`${latest_arn}\`" +done + +echo "" echo "nodejs8.10:" echo "" diff --git a/publish-layers.sh b/publish-layers.sh index ad2fb2d..cf7ae94 100755 --- a/publish-layers.sh +++ b/publish-layers.sh @@ -2,6 +2,7 @@ NODEJS610_DIST=dist/nodejs610.zip NODEJS810_DIST=dist/nodejs810.zip +NODEJS10_DIST=dist/nodejs10.zip REGIONS=( ap-northeast-1 @@ -25,7 +26,7 @@ rm -rf dist mkdir -p dist function usage { - echo "./publish-layers.sh [nodejs6.10|nodejs8.10]" + echo "./publish-layers.sh [nodejs6.10|nodejs8.10|nodejs10.x]" exit 1 } @@ -108,6 +109,45 @@ case "$1" in echo "Public permissions set for nodejs8.10 Layer version ${nodejs810_version} in region ${region}" done ;; + "nodejs10.x") + echo "Building iopipe Layer for nodejs10.x" + npm install --prefix nodejs @iopipe/iopipe + zip -rq $NODEJS10_DIST nodejs + rm -rf nodejs package-lock.json + echo "Build complete: ${NODEJS10_DIST}" + + nodejs10_hash=$(git rev-parse HEAD) + nodejs10_s3key="iopipe-nodejs10.x/${nodejs10_hash}.zip" + + for region in "${REGIONS[@]}"; do + bucket_name="iopipe-layers-${region}" + + echo "Uploading ${NODEJS10_DIST} to s3://${bucket_name}/${nodejs10_s3key}" + aws --region $region s3 cp $NODEJS10_DIST "s3://${bucket_name}/${nodejs10_s3key}" + + echo "Publishing nodejs10.x layer to ${region}" + nodejs10_version=$(aws lambda publish-layer-version \ + --layer-name IOpipeNodeJS10 \ + --content "S3Bucket=${bucket_name},S3Key=${nodejs10_s3key}" \ + --description "IOpipe Layer for Node 10" \ + --compatible-runtimes nodejs10.x \ + --license-info "Apache 2.0" \ + --region $region \ + --output text \ + --query Version) + echo "published nodejs10.x layer version ${nodejs10_version} to ${region}" + + echo "Setting public permissions for nodejs10.x layer version ${nodejs10_version} in ${region}" + aws lambda add-layer-version-permission \ + --layer-name IOpipeNodeJS10 \ + --version-number $nodejs10_version \ + --statement-id public \ + --action lambda:GetLayerVersion \ + --principal "*" \ + --region $region + echo "Public permissions set for nodejs10.x Layer version ${nodejs10_version} in region ${region}" + done + ;; *) usage ;;