Skip to content

Commit 77bc71b

Browse files
feat: Add autodiscovery to secrets refresh section
1 parent 834a55c commit 77bc71b

File tree

1 file changed

+64
-31
lines changed

1 file changed

+64
-31
lines changed

content/en/agent/configuration/secrets-management.md

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Instead of hardcoding sensitive values like API keys or passwords in plaintext w
3131

3232
**Note**: This option is not available for FIPS-enabled Agents at this time.
3333

34-
Starting in Agent version `7.70`, the Datadog Agent natively supports several secret management solutions. Two new settings have been introduced to `datadog.yaml`: `secret_backend_type` and `secret_backend_config`.
34+
Starting in Agent version `7.70`, the Datadog Agent natively supports several secret management solutions. Two new settings have been introduced to `datadog.yaml`: `secret_backend_type` and `secret_backend_config`.
3535

3636
`secret_backend_type` is used to specify which secret management solution to use, and `secret_backend_config` holds additional configuration relevant to that solution.
3737

@@ -44,7 +44,7 @@ secret_backend_config:
4444
```
4545
4646
47-
More specific setup instructions depend on the backend type used. Refer to the appropriate section bellow for further information:
47+
More specific setup instructions depend on the backend type used. Refer to the appropriate section bellow for further information:
4848
4949
5050
{{% collapse-content title="AWS Secrets" level="h4" expanded=false id="id-for-secrets" %}}
@@ -80,7 +80,7 @@ DD_SECRET_BACKEND_TYPE="aws.secrets"
8080
DD_SECRET_BACKEND_CONFIG='{"aws_session":{"aws_region":"<AWS_REGION>"}}'
8181
```
8282

83-
After configuring the Agent to use AWS Secrets, you can reference any secrets in your configurations with `ENC[secretId;secretKey]`.
83+
After configuring the Agent to use AWS Secrets, you can reference any secrets in your configurations with `ENC[secretId;secretKey]`.
8484

8585
The ENC notation is composed of:
8686
* `secretId`: either the secret "friendly name" (for example, `/DatadogAgent/Production`) or the ARN (for example, `arn:aws:secretsmanager:us-east-1:123456789012:secret:/DatadogAgent/Production-FOga1K`).
@@ -117,7 +117,7 @@ secret_backend_config:
117117
[1000]: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html
118118
[1001]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
119119
[1002]: https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html
120-
[1003]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
120+
[1003]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
121121
[1004]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html
122122
[1005]: https://docs.aws.amazon.com/managedservices/latest/userguide/defaults-instance-profile.html
123123
[1006]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html
@@ -130,16 +130,16 @@ Configure the Datadog Agent to use AWS Secrets to resolve secrets in Helm using
130130

131131
##### Integration check
132132

133-
```sh
134-
datadog:
133+
```sh
134+
datadog:
135135
confd:
136136
# This is an example
137137
<INTEGRATION_NAME>.yaml: |-
138138
ad_identifiers:
139139
- <SHORT_IMAGE>
140140
instances:
141141
- [...]
142-
password: "ENC[secretId;secretKey]"
142+
password: "ENC[secretId;secretKey]"
143143
env:
144144
- name: DD_SECRET_BACKEND_TYPE
145145
value: "aws.secrets"
@@ -159,7 +159,7 @@ agents:
159159

160160
##### Cluster check: without cluster check runners enabled
161161
```sh
162-
datadog:
162+
datadog:
163163
env:
164164
- name: DD_SECRET_BACKEND_TYPE
165165
value: "aws.secrets"
@@ -170,19 +170,19 @@ agents:
170170
# IAM role ARN required to grant the Agent permissions to access the AWS secret
171171
serviceAccountAnnotations:
172172
eks.amazonaws.com/role-arn: <IAM_ROLE_ARN>
173-
clusterAgent:
173+
clusterAgent:
174174
confd:
175175
# This is an example
176176
<INTEGRATION_NAME>.yaml: |-
177177
cluster_check: true
178178
instances:
179179
- [...]
180-
password: "ENC[secretId;secretKey]"
180+
password: "ENC[secretId;secretKey]"
181181
```
182182

183183
##### Cluster check: with cluster check runners enabled
184184
```sh
185-
datadog:
185+
datadog:
186186
env:
187187
- name: DD_SECRET_BACKEND_TYPE
188188
value: "aws.secrets"
@@ -195,8 +195,8 @@ clusterAgent:
195195
cluster_check: true
196196
instances:
197197
- [...]
198-
password: "ENC[secretId;secretKey]"
199-
clusterChecksRunner:
198+
password: "ENC[secretId;secretKey]"
199+
clusterChecksRunner:
200200
enabled: true
201201
env:
202202
- name: DD_SECRET_BACKEND_TYPE
@@ -272,15 +272,15 @@ spec:
272272
# IAM role ARN required to grant the Agent permissions to access the AWS secret
273273
serviceAccountAnnotations:
274274
eks.amazonaws.com/role-arn: <IAM_ROLE_ARN>
275-
clusterAgent:
275+
clusterAgent:
276276
extraConfd:
277277
configDataMap:
278278
# This is an example
279279
<INTEGRATION_NAME>.yaml: |-
280280
cluster_check: true
281281
instances:
282282
- [...]
283-
password: "ENC[secretId;secretKey]"
283+
password: "ENC[secretId;secretKey]"
284284
```
285285

286286
<br>
@@ -309,23 +309,23 @@ spec:
309309
# IAM role ARN required to grant the Agent permissions to access the AWS secret
310310
serviceAccountAnnotations:
311311
eks.amazonaws.com/role-arn: <IAM_ROLE_ARN>
312-
clusterAgent:
312+
clusterAgent:
313313
extraConfd:
314314
configDataMap:
315315
# This is an example
316316
<INTEGRATION_NAME>.yaml: |-
317317
cluster_check: true
318318
instances:
319319
- [...]
320-
password: "ENC[secretId;secretKey]"
320+
password: "ENC[secretId;secretKey]"
321321
322322
```
323323

324324
{{% /tab %}}
325325
{{< /tabs >}}
326326

327327

328-
{{% /collapse-content %}}
328+
{{% /collapse-content %}}
329329

330330
{{% collapse-content title="AWS SSM" level="h4" expanded=false id="id-for-ssm" %}}
331331
The following AWS services are supported:
@@ -367,12 +367,12 @@ property2: "ENC[/DatadogAgent/Production/ParameterKey2]"
367367
[1000]: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html
368368
[1001]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
369369
[1002]: https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html
370-
[1003]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
370+
[1003]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
371371
[1004]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html
372372
[1005]: https://docs.aws.amazon.com/managedservices/latest/userguide/defaults-instance-profile.html
373373
[1006]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html
374374

375-
{{% /collapse-content %}}
375+
{{% /collapse-content %}}
376376

377377

378378
{{% collapse-content title="Azure Keyvault Backend" level="h4" expanded=false id="id-for-azure" %}}
@@ -413,7 +413,7 @@ api_key: "ENC[secretKeyNameInKeyVault]"
413413

414414
[2000]: https://docs.microsoft.com/en-us/Azure/key-vault/secrets/quick-create-portal
415415

416-
{{% /collapse-content %}}
416+
{{% /collapse-content %}}
417417

418418

419419
{{% collapse-content title="HashiCorp Vault Backend" level="h4" expanded=false id="id-for-hashicorp" %}}
@@ -425,7 +425,7 @@ The following HashiCorp services are supported:
425425
| `hashicorp.vault` | [HashiCorp Vault (Secrets Engine Versions 1 and 2)][3000] |
426426

427427
##### How to set up HashiCorp Vault
428-
1. Run your HashiCorp Vault. See the [official HashiCorp Vault documentation][3001] for more information.
428+
1. Run your HashiCorp Vault. See the [official HashiCorp Vault documentation][3001] for more information.
429429
2. Write a policy that gives the permission to pull secrets from your vault. Create a `*.hcl` file, and include the following permission if using Secrets Engine Version 1:
430430
```
431431
path "<your mount path>/<additional subpath>" {
@@ -448,7 +448,7 @@ path "sys/mounts" {
448448
```
449449
3. Run `vault policy write <policy_name> <path_to_*.hcl_file>`
450450

451-
4. Choose the method of authenticating to your vault. If using the AWS instance profile method, run `vault auth enable aws`.
451+
4. Choose the method of authenticating to your vault. If using the AWS instance profile method, run `vault auth enable aws`.
452452

453453
##### AWS instance profile instructions
454454

@@ -468,7 +468,7 @@ The following example fetches the API key value from HashiCorp Vault leveraging
468468

469469
```yaml
470470
# datadog.yaml
471-
api_key: "ENC[/Datadog/Production;apikey]"
471+
api_key: "ENC[/Datadog/Production;apikey]"
472472
473473
secret_backend_type: hashicorp.vault
474474
secret_backend_config:
@@ -484,7 +484,7 @@ secret_backend_config:
484484
[3002]: https://developer.hashicorp.com/vault/docs/auth/aws#aws-auth-method
485485
[3003]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html
486486
[3004]: https://developer.hashicorp.com/vault/docs/auth/aws#iam-authentication-inferences
487-
{{% /collapse-content %}}
487+
{{% /collapse-content %}}
488488

489489
{{% collapse-content title="JSON or YAML File Secret Backends" level="h4" expanded=false id="id-for-json-yaml" %}}
490490

@@ -556,7 +556,7 @@ secret_backend_config:
556556
[4001]: https://en.wikipedia.org/wiki/JSON
557557
[4002]: https://en.wikipedia.org/wiki/YAML
558558

559-
{{% /collapse-content %}}
559+
{{% /collapse-content %}}
560560

561561

562562
### Option 2: Using the built-in Script for Kubernetes and Docker
@@ -833,9 +833,22 @@ On Windows, your executable must:
833833

834834
**Note**: Your executable shares the same environment variables as the Agent.
835835

836-
## Refreshing API/APP keys at runtime
836+
## Refreshing secrets at runtime
837837

838-
Starting in Agent version v7.67, you can configure the Agent to refresh its API and APP keys at regular intervals without requiring a restart. This relies on the API key and APP key being pulled as secrets.
838+
Starting in Agent version v7.67, you can configure the Agent to refresh resolved secrets at regular intervals without requiring a restart.
839+
840+
Secret refresh can be set as an interval:
841+
```yaml
842+
secret_refresh_interval: 3600 # refresh every hour
843+
```
844+
845+
Or triggered manually:
846+
```shell
847+
datadog-agent secret refresh
848+
```
849+
850+
### API/APP key refresh
851+
API/APP keys can be refreshed at runtime if they are pulled as secrets.
839852

840853
To enable this, set `secret_refresh_interval` (in seconds) in your `datadog.yaml` file:
841854
```yaml
@@ -857,9 +870,29 @@ You can disable this behavior by setting:
857870
secret_refresh_scatter: false
858871
```
859872

860-
To refresh manually, use:
861-
```
862-
datadog-agent secret refresh
873+
### Autodiscovery check secrets refresh
874+
As of Agent v7.76, scheduled [Autodiscovery][1] checks can refresh secrets at runtime as long as the configured template
875+
pulls secrets using the `ENC[]` syntax.
876+
877+
```yaml
878+
labels:
879+
tags.datadoghq.com/redis.env: "prod"
880+
tags.datadoghq.com/redis.service: "my-redis"
881+
tags.datadoghq.com/redis.version: "6.0.3"
882+
annotations:
883+
ad.datadoghq.com/redis.checks: |
884+
{
885+
"redisdb": {
886+
"init_config": {},
887+
"instances": [
888+
{
889+
"host": "%%host%%",
890+
"port":"6379",
891+
"password":"ENC[<secret_handle>]"
892+
}
893+
]
894+
}
895+
}
863896
```
864897

865898
### Enabling DDOT collector refresh

0 commit comments

Comments
 (0)