Enabling ASM for AWS Lambda
ASM support for AWS Lambda is in beta. Threat detection is done by using the Lambda extension.
You can monitor your functions running in AWS Lambda with Datadog Application Security Management (ASM). See Compatibility for information about what ASM features are supported for serverless functions.
In general, setting up ASM for AWS Lambda involves:
- Identifying functions that are vulnerable or are under attack, which would most benefit from ASM. Find them on the Security tab of your Service Catalog.
- Setting up ASM instrumentation by using the Datadog Serverless Framework plugin or manually setting the different layers.
- Triggering security signals in your application and seeing how Datadog displays the resulting information.
Prerequisites
- Serverless APM is configured on the Lambda function to send traces directly to Datadog. The X-Ray integration for sending trace data to APM does not support the data ASM needs to monitor functions.
Get started
The Datadog Serverless Framework plugin automatically configures your functions to send metrics, traces, and logs to Datadog through the Datadog Lambda Extension.
To install and configure the Datadog Serverless Framework plugin:
- Install the Datadog Serverless Framework plugin:
serverless plugin install --name serverless-plugin-datadog
- Enable ASM by updating your
serverless.yml
(or whichever way you set environment variables for your function):environment:
DD_SERVERLESS_APPSEC_ENABLED: true
For Go functions only also add:environment:
DD_UNIVERSAL_INSTRUMENTATION: true
For NodeJS or Python functions also add:environment:
DD_EXPERIMENTAL_ENABLE_PROXY: true
AWS_LAMBDA_EXEC_WRAPPER: /opt/datadog_wrapper
- Redeploy the function and invoke it. After a few minutes, it appears in ASM views.
- Install the Datadog tracer:
- Java: Configure the layers for your Lambda function using the ARN in one of the following formats, depending on where your Lambda is deployed. Replace
<AWS_REGION>
with a valid AWS region such as us-east-1
:# In AWS commercial regions
arn:aws:lambda:<AWS_REGION>:464622532012:layer:dd-trace-java:8
# In AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-java:8
- Go: The Go tracer doesn’t rely on a layer and is a regular Go module. You can upgrade to its latest version with:
go get -u github.com/DataDog/datadog-lambda-go
- .NET: Configure the layers for your Lambda function using the ARN in one of the following formats, depending on where your Lambda is deployed. Replace
<AWS_REGION>
with a valid AWS region such as us-east-1
:# x86-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:464622532012:layer:dd-trace-dotnet:6
# arm64-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:464622532012:layer:dd-trace-dotnet-ARM:6
# x86-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-dotnet:6
# arm64-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-dotnet-ARM:6
- Install the Datadog Lambda Extension by configuring the layers for your Lambda function using the ARN in one of the following formats. Replace
<AWS_REGION>
with a valid AWS region such as us-east-1
:# x86-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Extension:36
# arm64-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Extension-ARM:36
# x86-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:Datadog-Extension:36
# arm64-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:Datadog-Extension-ARM:36
Install the Datadog tracer:
- Java: Configure the layers for your Lambda function using the ARN in one of the following formats, depending on where your Lambda is deployed. Replace
<AWS_REGION>
with a valid AWS region such as us-east-1
:# In AWS commercial regions
arn:aws:lambda:<AWS_REGION>:417141415827:layer:dd-trace-java:8
# In AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-java:8
- Go: The Go tracer doesn’t rely on a layer and is a regular Go module. You can upgrade to its latest version with:
go get -u github.com/DataDog/datadog-lambda-go
- .NET: Configure the layers for your Lambda function using the ARN in one of the following formats, depending on where your Lambda is deployed. Replace
<AWS_REGION>
with a valid AWS region such as us-east-1
:# x86-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:417141415827:layer:dd-trace-dotnet:6
# arm64-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:417141415827:layer:dd-trace-dotnet-ARM:6
# x86-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-dotnet:6
# arm64-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:dd-trace-dotnet-ARM:6
Install the Datadog Lambda Extension by configuring the layers for your Lambda function using the ARN in one of the following formats. Replace <AWS_REGION>
with a valid AWS region such as us-east-1
:
# x86-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:417141415827:layer:Datadog-Extension:36
# arm64-based Lambda in AWS commercial regions
arn:aws:lambda:<AWS_REGION>:417141415827:layer:Datadog-Extension-ARM:36
# x86-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:Datadog-Extension:36
# arm64-based Lambda in AWS GovCloud regions
arn:aws-us-gov:lambda:<AWS_REGION>:002406178527:layer:Datadog-Extension-ARM:36
- Enable ASM by adding the following environment variables on your function deployment:
environment:
DD_SERVERLESS_APPSEC_ENABLED: true
For Go functions only also add:environment:
DD_UNIVERSAL_INSTRUMENTATION: true
For NodeJS or Python functions also add:environment:
DD_EXPERIMENTAL_ENABLE_PROXY: true
AWS_LAMBDA_EXEC_WRAPPER: /opt/datadog_wrapper
- Redeploy the function and invoke it. After a few minutes, it appears in ASM views.
To see Application Security Management threat detection in action, send known attack patterns to your application. For example, send an HTTP header with value acunetix-product
to trigger a security scanner attack attempt:
curl -H 'My-ASM-Test-Header: acunetix-product' https://your-function-url/existing-route
A few minutes after you enable your application and exercise it, threat information appears in the Application Signals Explorer.
Further reading
Additional helpful documentation, links, and articles: