During the initial setup phase, the setup script created an environment variable to make the configuration and deployment of instrumentation easier. Before we start configuring our Lambda functions, let’s make sure the environment variable is still available. To check, run the following in a terminal:
If the output is one of the AWS regions, then you are good to go! Otherwise, execute the following command to save the current region as an environment variable:
export AWS_REGION=$(aws configure get region)
In the Cloud9 workspace, expand the appd_aws_lambda_lab folder, then expand the java subfolder. Double-click on the file serverless.yml to open.
This file is used by the Serverless framework to provision the AWS Lambda function and all of the other AWS resources needed by the Lambda function. This file contains multiple sections, but the important ones are highlighted below:
Next, open up the file named lambda-environment-vars.txt located in the appd_aws_lambda_lab folder. This file contains values for all of the environment variables that will be updated within serverless.yml.
With both files open, take the values for each of the variables listed in lambda-environment-vars.txt and set the corresponding variables under the provder section in serverless.yml to the appropriate value. Next, set the value of the APPDYNAMICS_SERVERLESS_API_ENDPOINT environment variable to
The tracer sends metrics collected from each Lambda function invocation to the API endpoint specified in the APPDYNAMICS_SERVERLESS_API_ENDPOINT environment variable. In the above example, the API endpoint is located in the US. There are API endpoints available in Europe (
https://fra-sls-agent-api.saas.appdynamics.com) and Asia Pacific (
Save your changes. In the next section, we will be adding code to our Java Lambda function to add automatic instrumentation to one of our Lambda functions.