Skip to content

Commit b65ba78

Browse files
authored
[SVLS-7858] Update lambda CDK installation docs (#32505)
* Update Java CDK install docs * Refactor out to separate file * Template out CDK instructions and add for all runtimes * Remove comment * Separate code blocks for v1 and v2
1 parent de5faf9 commit b65ba78

File tree

7 files changed

+155
-148
lines changed

7 files changed

+155
-148
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ The [Datadog CloudFormation macro][1] automatically transforms your SAM applicat
159159
[3]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
160160
[4]: https://app.datadoghq.com/organization-settings/api-keys
161161
{{% /tab %}}
162+
163+
{{% tab "AWS CDK" %}}
164+
{{< lambda-install-cdk language="dotnet" layer="dd-trace-dotnet" layerParamTypescript="dotnetLayerVersion" layerParamPython="dotnet_layer_version">}}
165+
{{% /tab %}}
166+
162167
{{% tab "Container image" %}}
163168

164169
1. Install the Datadog Lambda Extension

content/en/serverless/aws_lambda/instrumentation/go.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ For more information and additional settings, see the [plugin documentation][1].
5959
[3]: https://docs.datadoghq.com/getting_started/site/
6060
[4]: https://app.datadoghq.com/organization-settings/api-keys
6161
{{% /tab %}}
62+
63+
{{% tab "AWS CDK" %}}
64+
{{< lambda-install-cdk language="go" >}}
65+
{{% /tab %}}
66+
6267
{{% tab "Container Image" %}}
6368

6469
1. Install the Datadog Lambda Extension

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

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -166,77 +166,11 @@ The [Datadog CloudFormation macro][1] automatically transforms your SAM applicat
166166
[3]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
167167
[4]: https://app.datadoghq.com/organization-settings/api-keys
168168
{{% /tab %}}
169-
{{% tab "AWS CDK" %}}
170-
171-
<div class="alert alert-info">Instrumenting Java functions through the Datadog CDK construct is only available for AWS CDK apps written in Node.js and Python.</div>
172-
173-
The [Datadog CDK construct][1] automatically installs Datadog on your functions using Lambda layers. It configures your functions to send metrics, traces, and logs to Datadog through the Datadog Lambda Extension.
174-
175-
1. Install the Datadog CDK constructs library
176169

177-
**Node.js**:
178-
```sh
179-
# For AWS CDK v1
180-
npm install datadog-cdk-constructs --save-dev
181-
182-
# For AWS CDK v2
183-
npm install datadog-cdk-constructs-v2 --save-dev
184-
```
185-
186-
**Python**:
187-
```sh
188-
# For AWS CDK v1
189-
pip install datadog-cdk-constructs
190-
191-
# For AWS CDK v2
192-
pip install datadog-cdk-constructs-v2
193-
```
194-
195-
2. Instrument your Lambda functions
196-
197-
**Node.js**:
198-
```javascript
199-
// For AWS CDK v1
200-
import { Datadog } from "datadog-cdk-constructs";
201-
202-
// For AWS CDK v2
203-
import { Datadog } from "datadog-cdk-constructs-v2";
204-
205-
const datadog = new Datadog(this, "Datadog", {
206-
javaLayerVersion: {{< latest-lambda-layer-version layer="dd-trace-java" >}},
207-
extensionLayerVersion: {{< latest-lambda-layer-version layer="extension" >}},
208-
site: "<DATADOG_SITE>",
209-
apiKeySecretArn: "<DATADOG_API_KEY_SECRET_ARN>"
210-
});
211-
datadog.addLambdaFunctions([<LAMBDA_FUNCTIONS>])
212-
```
213-
214-
**Python**:
215-
```python
216-
# For AWS CDK v1
217-
from datadog_cdk_constructs import Datadog
218-
219-
# For AWS CDK v2
220-
from datadog_cdk_constructs_v2 import Datadog
221-
222-
datadog = Datadog(self, "Datadog",
223-
java_layer_version={{< latest-lambda-layer-version layer="dd-trace-java" >}},
224-
extension_layer_version={{< latest-lambda-layer-version layer="extension" >}},
225-
site="<DATADOG_SITE>",
226-
api_key_secret_arn="<DATADOG_API_KEY_SECRET_ARN>",
227-
)
228-
datadog.add_lambda_functions([<LAMBDA_FUNCTIONS>])
229-
```
230-
231-
To fill in the placeholders:
232-
- Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}} (ensure the correct SITE is selected on the right).
233-
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your [Datadog API key][2] is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). Ensure your Lambda execution role has the `secretsmanager:GetSecretValue` IAM permission in order to read the secret value. For quick testing, you can use `apiKey` instead and set the Datadog API key in plaintext.
234-
235-
More information and additional parameters can be found on the [Datadog CDK documentation][1].
236-
237-
[1]: https://github.com/DataDog/datadog-cdk-constructs
238-
[2]: https://app.datadoghq.com/organization-settings/api-keys
170+
{{% tab "AWS CDK" %}}
171+
{{< lambda-install-cdk language="java" layer="dd-trace-java" layerParamTypescript="javaLayerVersion" layerParamPython="java_layer_version">}}
239172
{{% /tab %}}
173+
240174
{{% tab "Container image" %}}
241175

242176
1. Install the Datadog Lambda Extension

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

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -175,48 +175,11 @@ The [Datadog CloudFormation macro][1] automatically transforms your SAM applicat
175175
[3]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
176176
[4]: https://app.datadoghq.com/organization-settings/api-keys
177177
{{% /tab %}}
178-
{{% tab "AWS CDK" %}}
179-
180-
The [Datadog CDK Construct][1] automatically installs Datadog on your functions using Lambda Layers, and configures your functions to send metrics, traces, and logs to Datadog through the Datadog Lambda Extension.
181-
182-
1. Install the Datadog CDK constructs library
183-
184-
```sh
185-
# For AWS CDK v1
186-
npm install datadog-cdk-constructs --save-dev
187-
188-
# For AWS CDK v2
189-
npm install datadog-cdk-constructs-v2 --save-dev
190-
```
191-
192-
2. Instrument your Lambda functions
193-
194-
```javascript
195-
// For AWS CDK v1
196-
import { Datadog } from "datadog-cdk-constructs";
197178

198-
// For AWS CDK v2
199-
import { DatadogLambda } from "datadog-cdk-constructs-v2";
200-
201-
const datadogLambda = new DatadogLambda(this, "DatadogLambda", {
202-
nodeLayerVersion: {{< latest-lambda-layer-version layer="node" >}},
203-
extensionLayerVersion: {{< latest-lambda-layer-version layer="extension" >}},
204-
site: "<DATADOG_SITE>",
205-
apiKeySecretArn: "<DATADOG_API_KEY_SECRET_ARN>"
206-
});
207-
datadogLambda.addLambdaFunctions([<LAMBDA_FUNCTIONS>])
208-
```
209-
210-
To fill in the placeholders:
211-
- Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}} (ensure the correct SITE is selected on the right).
212-
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your [Datadog API key][2] 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 use `apiKey` instead and set the Datadog API key in plaintext.
213-
- Replace `<LAMBDA_FUNCTIONS>` with your Lambda functions.
214-
215-
More information and additional parameters can be found on the [Datadog CDK documentation][1].
216-
217-
[1]: https://github.com/DataDog/datadog-cdk-constructs
218-
[2]: https://app.datadoghq.com/organization-settings/api-keys
179+
{{% tab "AWS CDK" %}}
180+
{{< lambda-install-cdk language="node" layer="node" layerParamTypescript="nodeLayerVersion" layerParamPython="node_layer_version">}}
219181
{{% /tab %}}
182+
220183
{{% tab "Container Image" %}}
221184

222185
1. Install the Datadog Lambda Library

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

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -172,47 +172,10 @@ The [Datadog CloudFormation macro][1] automatically transforms your SAM applicat
172172
[3]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
173173
[4]: https://app.datadoghq.com/organization-settings/api-keys
174174
{{% /tab %}}
175-
{{% tab "AWS CDK" %}}
176-
177-
The [Datadog CDK Construct][1] automatically installs Datadog on your functions using Lambda Layers, and configures your functions to send metrics, traces, and logs to Datadog through the Datadog Lambda Extension.
178-
179-
1. Install the Datadog CDK constructs library
180-
181-
```sh
182-
# For AWS CDK v1
183-
pip install datadog-cdk-constructs
184-
185-
# For AWS CDK v2
186-
pip install datadog-cdk-constructs-v2
187-
```
188-
189-
2. Instrument your Lambda functions
190-
191-
```python
192-
# For AWS CDK v1
193-
from datadog_cdk_constructs import Datadog
194-
195-
# For AWS CDK v2
196-
from datadog_cdk_constructs_v2 import DatadogLambda
197-
198-
datadog_lambda = DatadogLambda(self, "DatadogLambda",
199-
python_layer_version={{< latest-lambda-layer-version layer="python" >}},
200-
extension_layer_version={{< latest-lambda-layer-version layer="extension" >}},
201-
site="<DATADOG_SITE>",
202-
api_key_secret_arn="<DATADOG_API_KEY_SECRET_ARN>",
203-
)
204-
datadog_lambda.add_lambda_functions([<LAMBDA_FUNCTIONS>])
205-
```
206175

207-
To fill in the placeholders:
208-
- Replace `<DATADOG_SITE>` with {{< region-param key="dd_site" code="true" >}} (ensure the correct SITE is selected on the right).
209-
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your [Datadog API key][2] 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 use `apiKey` instead and set the Datadog API key in plaintext.
210-
- Replace `<LAMBDA_FUNCTIONS>` with your Lambda functions.
211-
212-
More information and additional parameters can be found on the [Datadog CDK documentation][1].
176+
{{% tab "AWS CDK" %}}
177+
{{< lambda-install-cdk language="python" layer="python" layerParamTypescript="pythonLayerVersion" layerParamPython="python_layer_version">}}
213178

214-
[1]: https://github.com/DataDog/datadog-cdk-constructs
215-
[2]: https://app.datadoghq.com/organization-settings/api-keys
216179
{{% /tab %}}
217180
{{% tab "Container Image" %}}
218181

content/en/serverless/aws_lambda/instrumentation/ruby.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ To install and configure the Datadog Serverless Plugin, follow these steps:
157157
[2]: https://docs.datadoghq.com/serverless/libraries_integrations/extension
158158
[3]: https://app.datadoghq.com/organization-settings/api-keys
159159
{{% /tab %}}
160+
161+
{{% tab "AWS CDK" %}}
162+
{{< lambda-install-cdk language="ruby" layer="ruby" layerParamTypescript="rubyLayerVersion" layerParamPython="ruby_layer_version">}}
163+
{{% /tab %}}
164+
160165
{{% tab "Container Image" %}}
161166

162167
1. Install the Datadog Lambda Library
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{{ $language := .Get "language" }}
2+
{{ $layer := .Get "layer" }}
3+
{{ $layerParamPython := .Get "layerParamPython" }}
4+
{{ $layerParamTypescript := .Get "layerParamTypescript" }}
5+
{{ $layerParamGo := title $layerParamTypescript }}
6+
{{ $layerVersion := "" }}
7+
{{ if $layer }}
8+
{{ $layerVersion = trim ($.Page.RenderString (printf "{{< latest-lambda-layer-version layer=%q >}}" $layer)) "\n\r\t " }}
9+
{{ end }}
10+
{{ $layerExtensionVersion := trim ($.Page.RenderString "{{< latest-lambda-layer-version layer=\"extension\" >}}") "\n\r\t " }}
11+
{{ $site := $.Page.RenderString "{{< region-param key=\"dd_site\" code=\"true\" >}}" }}
12+
13+
<div class="alert alert-info">Instrumenting {{ title $language }} functions through the Datadog CDK construct is only available for AWS CDK apps written in Typescript, Python, and Go.</div>
14+
15+
The [Datadog CDK construct][1] automatically installs Datadog on your functions using Lambda layers. It configures your functions to send metrics, traces, and logs to Datadog through the Datadog Lambda Extension.
16+
17+
### TypeScript
18+
19+
1. Install the Datadog CDK constructs library
20+
21+
For AWS CDK v1:
22+
```sh
23+
npm install datadog-cdk-constructs --save-dev
24+
```
25+
For AWS CDK v2:
26+
```sh
27+
npm install datadog-cdk-constructs-v2 --save-dev
28+
```
29+
30+
2. Instrument your Lambda functions
31+
32+
For AWS CDK v1:
33+
```typescript
34+
import { Datadog } from "datadog-cdk-constructs";
35+
36+
const datadog = new Datadog(this, "Datadog", {
37+
{{ if $layerParamTypescript }}{{ $layerParamTypescript }}: {{ $layerVersion }},
38+
{{ end }}extensionLayerVersion: {{ $layerExtensionVersion }},
39+
site: "<DATADOG_SITE>",
40+
apiKeySecretArn: "<DATADOG_API_KEY_SECRET_ARN>"
41+
});
42+
datadog.addLambdaFunctions([<LAMBDA_FUNCTIONS>])
43+
```
44+
For AWS CDK v2:
45+
```typescript
46+
import { DatadogLambda } from "datadog-cdk-constructs-v2";
47+
48+
const datadogLambda = new DatadogLambda(this, "datadogLambda", {
49+
{{ if $layerParamTypescript }}{{ $layerParamTypescript }}: {{ $layerVersion }},
50+
{{ end }}extensionLayerVersion: {{ $layerExtensionVersion }},
51+
site: "<DATADOG_SITE>",
52+
apiKeySecretArn: "<DATADOG_API_KEY_SECRET_ARN>"
53+
});
54+
datadogLambda.addLambdaFunctions([<LAMBDA_FUNCTIONS>])
55+
```
56+
57+
### Python
58+
59+
1. Install the Datadog CDK constructs library
60+
61+
For AWS CDK v1:
62+
```sh
63+
pip install datadog-cdk-constructs
64+
```
65+
For AWS CDK v2:
66+
```sh
67+
pip install datadog-cdk-constructs-v2
68+
```
69+
70+
2. Instrument your Lambda functions
71+
72+
For AWS CDK v1:
73+
```python
74+
from datadog_cdk_constructs import Datadog
75+
datadog = Datadog(self, "Datadog",
76+
{{ if $layerParamPython }}{{ $layerParamPython }}={{ $layerVersion }},
77+
{{ end }}extension_layer_version={{ $layerExtensionVersion }},
78+
site="<DATADOG_SITE>",
79+
api_key_secret_arn="<DATADOG_API_KEY_SECRET_ARN>",
80+
)
81+
datadog.add_lambda_functions([<LAMBDA_FUNCTIONS>])
82+
```
83+
For AWS CDK v2:
84+
```python
85+
from datadog_cdk_constructs_v2 import DatadogLambda
86+
87+
datadog = DatadogLambda(self, "datadogLambda",
88+
{{ if $layerParamPython }}{{ $layerParamPython }}={{ $layerVersion }},
89+
{{ end }}extension_layer_version={{ $layerExtensionVersion }},
90+
site="<DATADOG_SITE>",
91+
api_key_secret_arn="<DATADOG_API_KEY_SECRET_ARN>",
92+
)
93+
datadog.add_lambda_functions([<LAMBDA_FUNCTIONS>])
94+
```
95+
96+
### Go
97+
98+
**Note**: Go CDK constructs are only available for AWS CDK v2.
99+
100+
1. Install the Datadog CDK constructs library
101+
102+
```sh
103+
go get github.com/DataDog/datadog-cdk-constructs-go/ddcdkconstruct/v3
104+
```
105+
106+
2. Instrument your Lambda functions
107+
108+
```go
109+
import (
110+
"github.com/DataDog/datadog-cdk-constructs-go/ddcdkconstruct/v3"
111+
)
112+
113+
datadogLambda := ddcdkconstruct.NewDatadogLambda(
114+
stack,
115+
jsii.String("Datadog"),
116+
&ddcdkconstruct.DatadogLambdaProps{
117+
{{ if $layerParamGo }}{{ $layerParamGo }}: jsii.Number({{ $layerVersion }}),
118+
{{ end }}ExtensionLayerVersion: jsii.Number({{ $layerExtensionVersion }}),
119+
Site: jsii.String("<DATADOG_SITE>"),
120+
ApiKeySecretArn: jsii.String("<DATADOG_API_KEY_SECRET_ARN>"),
121+
})
122+
datadogLambda.AddLambdaFunctions(&[]interface{}{<LAMBDA_FUNCTIONS>}, nil)
123+
```
124+
125+
To fill in the placeholders:
126+
- Replace `<DATADOG_SITE>` with {{ $site }} (ensure the correct SITE is selected on the right).
127+
- Replace `<DATADOG_API_KEY_SECRET_ARN>` with the ARN of the AWS secret where your [Datadog API key][2] is securely stored. The key needs to be stored as a plaintext string (not a JSON blob). Ensure your Lambda execution role has the `secretsmanager:GetSecretValue` IAM permission in order to read the secret value. For quick testing, you can use `apiKey` instead and set the Datadog API key in plaintext.
128+
129+
More information and additional parameters can be found on the [Datadog CDK documentation][1].
130+
131+
[1]: https://github.com/DataDog/datadog-cdk-constructs
132+
[2]: https://app.datadoghq.com/organization-settings/api-keys

0 commit comments

Comments
 (0)