Skip to content

Commit dc9316e

Browse files
Update Lambda Extension Installation Instructions for Datadog Lambda Terraform Module (.NET and Java) (#23954)
* bump to latest lambda datadog terraform module version * bump to latest supported python version * update documentation for instrumenting java lambda with terraform * update documentation for instrumenting .net lambda with terraform
1 parent b4d5fb6 commit dc9316e

File tree

4 files changed

+99
-229
lines changed

4 files changed

+99
-229
lines changed

content/en/serverless/aws_lambda/installation/dotnet.md

Lines changed: 47 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -191,121 +191,60 @@ The [Datadog CloudFormation macro][1] automatically transforms your SAM applicat
191191
{{% /tab %}}
192192
{{% tab "Terraform" %}}
193193

194-
Use this format for your [Terraform resource][1]:
195-
```sh
196-
resource "aws_lambda_function" "lambda" {
197-
"function_name" = ...
198-
...
199-
200-
# Remember sure to choose the right layers based on your Lambda architecture and AWS regions
201-
202-
layers = [
203-
<DATADOG_TRACER_ARN>,
204-
<DATADOG_EXTENSION_ARN>
205-
]
206-
207-
environment {
208-
variables = {
209-
DD_SITE = <DATADOG_SITE>
210-
DD_API_KEY_SECRET_ARN = <API_KEY>
211-
AWS_LAMBDA_EXEC_WRAPPER = "/opt/datadog_wrapper"
212-
}
194+
The [`lambda-datadog`][1] Terraform module wraps the [`aws_lambda_function`][2] resource and automatically configures your Lambda function for Datadog Serverless Monitoring by:
195+
196+
- Adding the Datadog Lambda layers
197+
- Redirecting the Lambda handler
198+
- Enabling the collection and sending of metrics, traces, and logs to Datadog
199+
200+
```tf
201+
module "lambda-datadog" {
202+
source = "DataDog/lambda-datadog/aws"
203+
version = "1.2.0"
204+
205+
environment_variables = {
206+
"DD_API_KEY_SECRET_ARN" : "<DATADOG_API_KEY_SECRET_ARN>"
207+
"DD_ENV" : "<ENVIRONMENT>"
208+
"DD_SERVICE" : "<SERVICE_NAME>"
209+
"DD_SITE": "<DATADOG_SITE>"
210+
"DD_VERSION" : "<VERSION>"
213211
}
212+
213+
datadog_extension_layer_version = 58
214+
datadog_dotnet_layer_version = 15
215+
216+
# aws_lambda_function arguments
214217
}
215218
```
216219

217-
Fill in variables accordingly:
218-
219-
1. Replace `<DATADOG_TRACER_ARN>` with the ARN of the appropriate Datadog tracer for your region and architecture:
220-
221-
<table>
222-
<tr>
223-
<th>AWS REGIONS</th>
224-
<th>ARCHITECTURE</th>
225-
<th>LAYER</th>
226-
</tr>
227-
<tr>
228-
<td rowspan=2>Commercial</td>
229-
<td>x86_64</td>
230-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:dd-trace-dotnet:{{< latest-lambda-layer-version layer="dd-trace-dotnet" >}}</code></td>
231-
<tr>
232-
<td>arm64</td>
233-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:dd-trace-dotnet-ARM:{{< latest-lambda-layer-version layer="dd-trace-dotnet" >}}</code></td>
234-
</tr>
235-
<tr>
236-
<td rowspan=2>GovCloud</td>
237-
<td>x86_64</td>
238-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:002406178527:layer:dd-trace-dotnet:{{< latest-lambda-layer-version layer="dd-trace-dotnet" >}}</code></td>
239-
<tr>
240-
<td>arm64</td>
241-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:002406178527:layer:dd-trace-dotnet-ARM:{{< latest-lambda-layer-version layer="dd-trace-dotnet" >}}</code></td>
242-
</tr>
243-
</table>
244-
245-
In the ARN, replace `<AWS_REGION>` with a valid AWS region, such as `us-east-1`.
246-
247-
2. Replace `<DATADOG_EXTENSION_ARN>` with the ARN of the appropriate Datadog Lambda Extension for your region and architecture:
248-
249-
<table>
250-
<tr>
251-
<th>AWS REGIONS</th>
252-
<th>ARCHITECTURE</th>
253-
<th>LAYER</th>
254-
</tr>
255-
<tr>
256-
<td rowspan=2>Commercial</td>
257-
<td>x86_64</td>
258-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}</code></td>
259-
<tr>
260-
<td>arm64</td>
261-
<td><code>arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:Datadog-Extension-ARM:{{< latest-lambda-layer-version layer="extension" >}}</code></td>
262-
</tr>
263-
<tr>
264-
<td rowspan=2>GovCloud</td>
265-
<td>x86_64</td>
266-
<td><code>arn:aws-us-gov:lambda:&lt;AWS_REGION&gt;:002406178527:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}</code></td>
267-
</tr>
268-
<tr>
269-
<td>arm64</td>
270-
<td><code>arn:aws-us-gov:lambda:&lt;AWS_REGION&gt;:002406178527:layer:Datadog-Extension-ARM:{{< latest-lambda-layer-version layer="extension" >}}</code></td>
271-
</tr>
272-
</table>
273-
274-
In the ARN, replace `<AWS_REGION>` with a valid AWS region, such as `us-east-1`.
275-
276-
3. Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}} (ensure the correct SITE is selected on the right).
277-
278-
4. Replace `<API_KEY>` with the ARN of the AWS secret where your Datadog API key is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). The `secretsmanager:GetSecretValue` permission is required. For quick testing, use `DD_API_KEY` instead of `DD_API_KEY_SECRET_ARN` and set the value to your Datadog API key in plaintext.
279-
280-
281-
#### Full example
282-
283-
```sh
284-
resource "aws_lambda_function" "lambda" {
285-
"function_name" = ...
286-
...
287-
288-
# Remember sure to choose the right layers based on your Lambda architecture and AWS regions
289-
290-
layers = [
291-
"arn:aws:lambda:us-east-1:464622532012:layer:dd-trace-dotnet:{{< latest-lambda-layer-version layer="dd-trace-dotnet" >}}",
292-
"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}"
293-
]
294-
295-
296-
environment {
297-
variables = {
298-
DD_SITE = "datadoghq.com"
299-
DD_API_KEY_SECRET_ARN = "arn:aws..."
300-
AWS_LAMBDA_EXEC_WRAPPER = "/opt/datadog_wrapper"
301-
}
302-
}
303-
}
220+
1. Replace the `aws_lambda_function` resource with the `lambda-datadog` Terraform module then specify the `source` and `version` of the module.
221+
222+
2. Set the `aws_lambda_function` arguments:
223+
224+
All of the arguments available in the `aws_lambda_function` resource are available in this Terraform module. Arguments defined as blocks in the `aws_lambda_function` resource are redefined as variables with their nested arguments.
225+
226+
For example, in `aws_lambda_function`, `environment` is defined as a block with a `variables` argument. In the `lambda-datadog` Terraform module, the value for the `environment_variables` is passed to the `environment.variables` argument in `aws_lambda_function`. See [inputs][3] for a complete list of variables in this module.
227+
228+
3. Fill in the environment variable placeholders:
229+
230+
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your Datadog API key is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). The `secretsmanager:GetSecretValue` permission is required. For quick testing, you can instead use the environment variable `DD_API_KEY` and set your Datadog API key in plaintext.
231+
- Replace `<ENVIRONMENT>` with the Lambda function's environment, such as `prod` or `staging`
232+
- Replace `<SERVICE_NAME>` with the name of the Lambda function's service
233+
- Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}}. (Ensure the correct [Datadog site][4] is selected on this page).
234+
- Replace `<VERSION>` with the version number of the Lambda function
235+
236+
4. Select the versions of the Datadog Extension Lambda layer and Datadog .NET Lambda layer to use. Defaults to the latest layer versions.
237+
238+
```
239+
datadog_extension_layer_version = 58
240+
datadog_dotnet_layer_version = 15
304241
```
305242

306-
[1]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function.html#lambda-layers
243+
[1]: https://registry.terraform.io/modules/DataDog/lambda-datadog/aws/latest
244+
[2]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function
245+
[3]: https://github.com/DataDog/terraform-aws-lambda-datadog?tab=readme-ov-file#inputs
246+
[4]: /getting_started/site/
307247
{{% /tab %}}
308-
309248
{{% tab "Custom" %}}
310249

311250
1. Install the Datadog Tracer

content/en/serverless/aws_lambda/installation/java.md

Lines changed: 48 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -263,129 +263,60 @@ The [Datadog CDK construct][1] automatically installs Datadog on your functions
263263
[2]: https://app.datadoghq.com/organization-settings/api-keys
264264
{{% /tab %}}
265265
{{% tab "Terraform" %}}
266-
Use this format for your [Terraform resource][1]:
267-
```sh
268-
resource "aws_lambda_function" "lambda" {
269-
"function_name" = ...
270-
...
271-
272-
# Remember sure to choose the right layers based on your Lambda architecture and AWS regions
273-
274-
layers = [
275-
<DATADOG_TRACER_ARN>,
276-
<DATADOG_EXTENSION_ARN>
277-
]
278-
279-
environment {
280-
variables = {
281-
DD_SITE = <DATADOG_SITE>
282-
DD_API_KEY_SECRET_ARN = <API_KEY>
283-
AWS_LAMBDA_EXEC_WRAPPER = "/opt/datadog_wrapper"
284-
}
266+
267+
The [`lambda-datadog`][1] Terraform module wraps the [`aws_lambda_function`][2] resource and automatically configures your Lambda function for Datadog Serverless Monitoring by:
268+
269+
- Adding the Datadog Lambda layers
270+
- Redirecting the Lambda handler
271+
- Enabling the collection and sending of metrics, traces, and logs to Datadog
272+
273+
```tf
274+
module "lambda-datadog" {
275+
source = "DataDog/lambda-datadog/aws"
276+
version = "1.2.0"
277+
278+
environment_variables = {
279+
"DD_API_KEY_SECRET_ARN" : "<DATADOG_API_KEY_SECRET_ARN>"
280+
"DD_ENV" : "<ENVIRONMENT>"
281+
"DD_SERVICE" : "<SERVICE_NAME>"
282+
"DD_SITE": "<DATADOG_SITE>"
283+
"DD_VERSION" : "<VERSION>"
285284
}
285+
286+
datadog_extension_layer_version = 58
287+
datadog_java_layer_version = 15
288+
289+
# aws_lambda_function arguments
286290
}
287291
```
288292
289-
Fill in variables accordingly:
290-
291-
1. Replace `<DATADOG_TRACER_ARN>` with the ARN of the appropriate Datadog tracer depending on your type of region:
292-
293-
<table>
294-
<tr>
295-
<th>AWS REGIONS</th>
296-
<th>LAYERS</th>
297-
</tr>
298-
<tr>
299-
<td>Commercial</td>
300-
<td>
301-
<code>
302-
arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:dd-trace-java:{{< latest-lambda-layer-version layer="dd-trace-java" >}}
303-
</code>
304-
</td>
305-
</tr>
306-
<tr>
307-
<td>GovCloud</td>
308-
<td>
309-
<code>
310-
arn:aws-us-gov:lambda:&lt;AWS_REGION&gt;:002406178527:layer:dd-trace-java:{{< latest-lambda-layer-version layer="dd-trace-java" >}}
311-
</code>
312-
</td>
313-
</tr>
314-
</table>
315-
316-
In each ARN, replace `<AWS_REGION>` with a valid AWS region, such as `us-east-1`.
317-
318-
2. Replace `<DATADOG_EXTENSION_ARN>` with the ARN of the appropriate Datadog Lambda Extension for your region and architecture:
319-
320-
<table>
321-
<tr>
322-
<th>AWS REGIONS</th>
323-
<th>ARCHITECTURE</th>
324-
<th>LAYERS</th>
325-
</tr>
326-
<tr>
327-
<td rowspan=2>Commercial</td>
328-
<td>x86_64</td>
329-
<td>
330-
<code>
331-
arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}
332-
</code>
333-
</td>
334-
<tr>
335-
<td>arm64</td>
336-
<td>
337-
<code>
338-
arn:aws:lambda:&lt;AWS_REGION&gt;:464622532012:layer:Datadog-Extension-ARM:{{< latest-lambda-layer-version layer="extension" >}}
339-
</code>
340-
</td>
341-
</tr>
342-
<tr>
343-
<td rowspan=2>GovCloud</td>
344-
<td>x86_64</td>
345-
<td>
346-
<code>
347-
arn:aws-us-gov:lambda:&lt;AWS_REGION&gt;:002406178527:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}
348-
</code>
349-
</td>
350-
<tr>
351-
<td>arm64</td>
352-
<td>
353-
<code>
354-
arn:aws-us-gov:lambda:&lt;AWS_REGION&gt;:002406178527:layer:Datadog-Extension-ARM:{{< latest-lambda-layer-version layer="extension" >}}
355-
</code>
356-
</td>
357-
</tr>
358-
</table>
359-
360-
3. Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}} (ensure the correct SITE is selected on the right).
361-
362-
4. Replace `<API_KEY>` with the ARN of the AWS secret where your Datadog API key is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). The `secretsmanager:GetSecretValue` permission is required. For quick testing, use `DD_API_KEY` instead of `DD_API_KEY_SECRET_ARN` and set the value to your Datadog API key in plaintext.
363-
364-
#### Full example
365-
366-
```sh
367-
resource "aws_lambda_function" "lambda" {
368-
"function_name" = ...
369-
...
370-
371-
# Remember sure to choose the right layers based on your Lambda architecture and AWS regions
372-
373-
layers = [
374-
"arn:aws:lambda:us-east-1:464622532012:layer:dd-trace-java:{{< latest-lambda-layer-version layer="dd-trace-java" >}}",
375-
"arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:{{< latest-lambda-layer-version layer="extension" >}}"
376-
]
377-
378-
environment {
379-
variables = {
380-
DD_SITE = datadoghq.com
381-
DD_API_KEY_SECRET_ARN = "arn:aws..."
382-
AWS_LAMBDA_EXEC_WRAPPER = "/opt/datadog_wrapper"
383-
}
384-
}
385-
}
293+
1. Replace the `aws_lambda_function` resource with the `lambda-datadog` Terraform module. Then, specify the `source` and `version` of the module.
294+
295+
2. Set the `aws_lambda_function` arguments:
296+
297+
All of the arguments available in the `aws_lambda_function` resource are available in this Terraform module. Arguments defined as blocks in the `aws_lambda_function` resource are redefined as variables with their nested arguments.
298+
299+
For example, in `aws_lambda_function`, `environment` is defined as a block with a `variables` argument. In the `lambda-datadog` Terraform module, the value for the `environment_variables` is passed to the `environment.variables` argument in `aws_lambda_function`. See [inputs][3] for a complete list of variables in this module.
300+
301+
3. Fill in the environment variable placeholders:
302+
303+
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your Datadog API key is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). The `secretsmanager:GetSecretValue` permission is required. For quick testing, you can instead use the environment variable `DD_API_KEY` and set your Datadog API key in plaintext.
304+
- Replace `<ENVIRONMENT>` with the Lambda function's environment, such as `prod` or `staging`
305+
- Replace `<SERVICE_NAME>` with the name of the Lambda function's service
306+
- Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}}. (Ensure the correct [Datadog site][4] is selected on this page).
307+
- Replace `<VERSION>` with the version number of the Lambda function
308+
309+
4. Select the versions of the Datadog Extension Lambda layer and Datadog Java Lambda layer to use. If left blank the latest layer versions will be used.
310+
311+
```
312+
datadog_extension_layer_version = 58
313+
datadog_java_layer_version = 15
386314
```
387315
388-
[1]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function.html#lambda-layers
316+
[1]: https://registry.terraform.io/modules/DataDog/lambda-datadog/aws/latest
317+
[2]: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function
318+
[3]: https://github.com/DataDog/terraform-aws-lambda-datadog?tab=readme-ov-file#inputs
319+
[4]: /getting_started/site/
389320
{{% /tab %}}
390321
{{% tab "Custom" %}}
391322

content/en/serverless/aws_lambda/installation/nodejs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ The [`lambda-datadog`][1] Terraform module wraps the [`aws_lambda_function`][2]
266266
```tf
267267
module "lambda-datadog" {
268268
source = "DataDog/lambda-datadog/aws"
269-
version = "1.1.0"
269+
version = "1.2.0"
270270
271271
environment_variables = {
272272
"DD_API_KEY_SECRET_ARN" : "<DATADOG_API_KEY_SECRET_ARN>"

content/en/serverless/aws_lambda/installation/python.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ The [`lambda-datadog`][1] Terraform module wraps the [`aws_lambda_function`][2]
257257
```tf
258258
module "lambda-datadog" {
259259
source = "DataDog/lambda-datadog/aws"
260-
version = "1.1.0"
260+
version = "1.2.0"
261261
262262
environment_variables = {
263263
"DD_API_KEY_SECRET_ARN" : "<DATADOG_API_KEY_SECRET_ARN>"
@@ -268,7 +268,7 @@ module "lambda-datadog" {
268268
}
269269
270270
datadog_extension_layer_version = 58
271-
datadog_python_layer_version = 95
271+
datadog_python_layer_version = 96
272272
273273
# aws_lambda_function arguments
274274
}
@@ -294,7 +294,7 @@ module "lambda-datadog" {
294294
295295
```
296296
datadog_extension_layer_version = 58
297-
datadog_python_layer_version = 95
297+
datadog_python_layer_version = 96
298298
```
299299
300300
[1]: https://registry.terraform.io/modules/DataDog/lambda-datadog/aws/latest

0 commit comments

Comments
 (0)