You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/aws-lambda/lambdas/README.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ Manually create the lambda function in the target region. The name needs to matc
12
12
Building The Lambda Zip Files
13
13
-----------------------------
14
14
15
+
Add `.dont-add-npm-instana` file to the target folder to avoid adding the Instana npm packages and to use the layer instead.
16
+
15
17
Run `bin/create-zip.sh <lambda-folder-name>` to create deployment zip files for one of Lambda functions in this folder. The resulting zip files can be found in the `zip` subfolder. They can be uploaded to AWS as Lambda functions. There is also a script to deploy the resulting zip file via the `aws` command line tool.
16
18
17
19
The environment variable `BUILD_LAMBDAS_WITH` controls how the Lambda zip files are being built:
@@ -26,11 +28,11 @@ Deploying Lambda Zip Files
26
28
27
29
Before you deploy zip files, you need to actually build them, see above.
28
30
29
-
Use `bin/deploy-zip.sh <lambda-folder-name>` to deploy a Lambda zip files. They will be deployed to region `us-east-2` by default. You can repeat that step as often as you like if the Lambda code has changed or you want to deploy zip files with a more recent npm package/local package/Lambda layer.
31
+
Use `bin/deploy-zip.sh <zip-file>` to deploy a Lambda zip files. They will be deployed to region `us-east-2` by default. You can repeat that step as often as you like if the Lambda code has changed or you want to deploy zip files with a more recent npm package/local package/Lambda layer.
30
32
31
33
If you have built the zip files with `BUILD_LAMBDAS_WITH=layer`, the script will try to add the Lambda layer "instana-nodejs" to the deployed Lambda function. The script will try to figure out the latest version of the Instana Node.js Lambda layer. Alternatively, you can also use `LAYER_VERSION` and `LAYER_ARN` to specifiy which layer you want to have added. Checkout the latest layers here: https://www.ibm.com/docs/en/instana-observability/current?topic=lambda-aws-native-tracing-nodejs
32
34
33
-
E.g. run something like `LAYER_VERSION=167 LAYER_ARN=arn:aws:lambda:ap-southeast-1:767398002385:layer:instana-nodejs:167 bin/deploy-zip.sh`.
35
+
E.g. run something like `LAYER_VERSION=167 LAYER_ARN=arn:aws:lambda:ap-southeast-1:767398002385:layer:instana-nodejs:167 bin/deploy-zip.sh <zip-file>`.
34
36
35
37
Note that if you have use `BUILD_LAMBDAS_WITH=npm` or `BUILD_LAMBDAS_WITH=local` and the function already has the Instana Lambda layer, the deploy script will try to remove it and revert the handler back to `index.handler`.
# (c) Copyright Instana Inc. and contributors 2019
6
-
#######################################
7
-
8
-
set -exEo pipefail
9
-
10
-
if [[ -z"${1-}" ]];then
11
-
echo"Usage $0 <lambda-folder-name>"
12
-
echo
13
-
echo"The mandatory argument <lambda-folder-name> is missing."
14
-
exit 1
15
-
fi
16
-
17
-
cd`dirname $BASH_SOURCE`/../zip
18
-
19
1
command -v aws >/dev/null 2>&1|| {
20
2
cat <<EOF >&2
21
3
The AWS command line tool needs to be installed but it isn't. See https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html or https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html etc. for instructions.
@@ -41,112 +23,189 @@ EOF
41
23
exit 1
42
24
}
43
25
44
-
REGION=us-east-2
26
+
INSTANA_ENDPOINT_URL=$INSTANA_ENDPOINT_URL
27
+
INSTANA_AGENT_KEY=$INSTANA_AGENT_KEY
28
+
REGION=$REGION
29
+
TIMEOUT=$TIMEOUT
30
+
MEMORY_SIZE=$MEMORY_SIZE
31
+
HANDLER=$HANDLER
32
+
FUNCTION_NAME_PREFIX=$FUNCTION_NAME_PREFIX
33
+
lambda_zip_file=$1
34
+
ROLE_ARN=$ROLE_ARN
35
+
FUNCTION_URL=$FUNCTION_URL
36
+
37
+
if [[ -z$REGION ]];then
38
+
REGION=us-east-1
39
+
fi
45
40
46
-
functiondeploy_zip {
47
-
lambda_zip_file=$1
41
+
if [[ -z$TIMEOUT ]];then
42
+
TIMEOUT=3
43
+
fi
48
44
49
-
if [[ !-e$lambda_zip_file ]];then
50
-
echo"Zip file $lambda_zip_file does not exist, terminating."
echo"The zip file $lambda_zip_file seems to contain the package @instana/aws-lambda (or a .dont-add-instana marker file), so I won't add the Lambda layer to it. I'll check if it currently has a layer that needs to be removed."
if [[ "$current_layers"=~":instana-nodejs:" ]];then
84
-
echo"This lambda function definition currently has the Instana layer configured, removing it now. I'll also set the standard handler index.handler (just in in case the auto-wrap handler had been configured previously)."
echo This lambda functiondefinition does not use the Instana layer, doing nothing.
91
-
fi
168
+
fi
92
169
170
+
echo
171
+
if [[ $needs_layer== 0 ]];then
172
+
echo"The zip file $lambda_zip_file seems to contain the package @instana/aws-lambda, so I won't add the Lambda layer to it. I'll check if it currently has a layer that needs to be removed."
if [[ "$current_layers"=~":instana-nodejs:" ]];then
180
+
echo"This lambda function definition currently has the Instana layer configured, removing it now. I'll also set the standard handler index.handler (just in in case the auto-wrap handler had been configured previously)."
# remove surrounding quotes from ARN as it trips up the aws lambda update-function-configuration command
105
-
LAYER_ARN=${LAYER_ARN//\"/}
106
-
fi
107
-
108
-
echo Using layer version: $LAYER_VERSION
109
-
echo Using layer ARN: $LAYER_ARN
110
-
111
-
if [[ -z$LAYER_VERSION||-z$LAYER_ARN||$LAYER_VERSION= null ||$LAYER_ARN= null ]];then
112
-
echo"I just found out that I'm supposed to add the Instana layer to the function I have just deployed. But I could not find out which LAYER_VERSION or LAYER_ARN to use, so I do not know which layer version I should deploy or what the ARN of that layer version is. The lambda zip file I have just deployed will probably be in a broken state now. Please fix this manually."
113
-
echo
114
-
echo"For your convenience, here are the commands to figure out the latest layer:"
if [[ "$current_layers"=~":instana-nodejs:$LAYER_VERSION" ]];then
130
-
echo This lambda functiondefinition already has the specified version of the Instana layer, doing nothing.
131
-
else
132
-
echo"This lambda function definition already has the Instana layer configured but uses a version ($current_layers) that is different from the one you specified ($LAYER_VERSION). I'll try to replace this with the specified layer. I'll also set the auto-wrap handler."
0 commit comments