Skip to content

Commit

Permalink
feat: Add nodejs10.x layers (#49)
Browse files Browse the repository at this point in the history
* feat: Add nodejs10.x layers

Closes #48

* Update README

* More README updates
  • Loading branch information
kolanos committed Jun 19, 2019
1 parent 2400709 commit 8f2866b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -112,3 +126,12 @@ workflows:
ignore: /.*/
tags:
only: /^v.*/
- publish-njs10:
requires:
- install
- test
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:

Expand All @@ -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):

Expand Down Expand Up @@ -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`

Expand Down
12 changes: 12 additions & 0 deletions latest-layer-arns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
42 changes: 41 additions & 1 deletion publish-layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

NODEJS610_DIST=dist/nodejs610.zip
NODEJS810_DIST=dist/nodejs810.zip
NODEJS10_DIST=dist/nodejs10.zip

REGIONS=(
ap-northeast-1
Expand All @@ -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
}

Expand Down Expand Up @@ -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
;;
Expand Down

0 comments on commit 8f2866b

Please sign in to comment.