@datadog/datadog-ci-plugin-ecs-fargate 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020 Datadog, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ You can use the CLI to instrument your AWS ECS Fargate task definitions with Datadog. The command adds the Datadog Agent as a sidecar container, sets the environment variables your tracers read, and registers a new task definition revision. Your container images are left untouched.
2
+
3
+ ## Commands
4
+
5
+ ### `instrument`
6
+
7
+ **Warning:** The `ecs-fargate instrument` command is in beta. It requires you to set `DD_BETA_COMMANDS_ENABLED=1`.
8
+
9
+ Run `datadog-ci ecs-fargate instrument` to add the Datadog Agent sidecar to an ECS Fargate task definition. The command reads the task definitions you name, adds the `datadog-agent` container to each of them, and registers the result as a new revision. Running tasks do not change until the new revision is deployed. Pass `--ecs-service` to have the command update the service for you.
10
+
11
+ ```bash
12
+ export DD_BETA_COMMANDS_ENABLED=1
13
+
14
+ # Instrument a task definition, reading the API key from an AWS Secrets Manager secret
15
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn>
16
+
17
+ # Instrument a specific revision, or a full task definition ARN
18
+ datadog-ci ecs-fargate instrument --task-definition my-app:3 -r us-east-1 --api-key-secret-arn <secret-arn>
19
+
20
+ # Instrument several task definitions in one run
21
+ datadog-ci ecs-fargate instrument --task-definition my-app --task-definition my-worker -r us-east-1 --api-key-secret-arn <secret-arn>
22
+
23
+ # Instrument a task definition and roll the new revision out to the service running it
24
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> \
25
+ --ecs-service my-app-service --cluster my-cluster
26
+
27
+ # Instrument with unified service tagging
28
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> \
29
+ --service my-service --env prod --version 1.0.0
30
+
31
+ # Send container logs to Datadog
32
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> \
33
+ --log-collection
34
+
35
+ # Detect the application language and add its tracer automatically
36
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> \
37
+ --tracing inject
38
+
39
+ # Copy one language tracer
40
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> \
41
+ --tracing inject --language nodejs
42
+
43
+ # Preview the changes without registering a revision
44
+ datadog-ci ecs-fargate instrument --task-definition my-app -r us-east-1 --api-key-secret-arn <secret-arn> --dry-run
45
+ ```
46
+
47
+ Application containers are given `DD_SERVICE`, `DD_ENV`, `DD_VERSION`, and `DD_TAGS` from the arguments above, so the traces, logs, and metrics your tracers send are tagged consistently. `DD_SERVICE` is `--service`, or the task definition family when `--service` is omitted, and is written to the application containers, the Agent, the Docker labels, and the revision tags so they cannot disagree. `DD_TRACE_ENABLED` follows `--tracing`: omitted and `manual` set it to `true`, and `disabled` sets it to `false`. `DD_LOGS_INJECTION` is set only when the container does not already set it. Other values you pass overwrite the task definition.
48
+
49
+ Product settings the command owns are applied when those flags are on and removed when they are not: `--no-appsec` drops `DD_APPSEC_ENABLED`, omitting `--llmobs` drops the LLM Observability variables, and `--no-source-code-integration` drops the Git tags from `DD_TAGS`.
50
+
51
+ The same three unified service tag values are also written to the application containers as the `com.datadoghq.tags.service`, `com.datadoghq.tags.env`, and `com.datadoghq.tags.version` Docker labels. The environment variables tag what a tracer running inside a container sends; these labels are what the Agent reads to tag the metrics it collects about the container from the outside, so the two line up in Datadog. The Agent container is deliberately left unlabeled, so that it reports its own resource usage under its own name rather than your service's. Labels that are not Datadog's are left alone.
52
+
53
+ #### Reaching the Agent
54
+
55
+ The tracers reach the Agent over a Unix socket by default. The command adds a `dd-sockets` volume to the task, mounts it at `/var/run/datadog` on both the Agent and your application containers, and points the tracers at it with `DD_TRACE_AGENT_URL` and `DD_DOGSTATSD_URL`. Pass `--no-agent-socket` to use the task's loopback address instead, which sets `DD_AGENT_HOST` to `127.0.0.1` and leaves the volume off. [Windows tasks](#windows-tasks) always use the loopback address.
56
+
57
+ These Agent connection settings are mutually exclusive. Switching from the Unix socket to loopback removes the socket path and volume so nothing is left pointing at a socket that is not listening.
58
+
59
+ #### Automatic tracer injection
60
+
61
+ Use `--tracing inject` to detect the application language and add its tracer without rebuilding the application image. Add `--language <language>` to copy only one tracer. Supported language values are `java`, `nodejs`, `csharp`, `python`, `ruby`, and `php`. `dotnet` is accepted as an alias for `csharp`. The command copies the tracer through a non-essential `datadog-tracer` container and waits for that copy to succeed before starting the selected application container. The Datadog Agent sidecar remains responsible for trace transport.
62
+
63
+ `--tracer-version` and `--tracer-libc` require `--tracing inject --language`. Single-language injection uses the `latest` tracer version and `glibc` by default. Omitting `--language` copies a larger composite tracer image than selecting one language. Ruby injection does not support musl, and .NET tracer versions before 3.0 are not supported. Automatic tracer injection is Linux-only, and .NET injection is not supported on ARM64 tasks. Go is not supported; install `dd-trace-go` in the application image and use `--tracing manual`.
64
+
65
+ When the task definition has more than one application container, specify the container to instrument with `--container-name`. The Agent, log router, and tracer sidecars are never selected. `--container-name` only applies with `--tracing inject`; passing it otherwise is reported and ignored. Omitting `--tracing` defaults to `manual`, which removes an injected tracer if one is present and reports that it did.
66
+
67
+ A tracer your own image installs is left alone. The command removes the startup settings it wrote, which it recognizes from the `/datadog-lib` and `/opt/datadog-packages` paths it copies tracers into. Settings a manual install shares with it, such as `CORECLR_ENABLE_PROFILING`, are only removed alongside one of those paths.
68
+
69
+ The following names and paths belong to this command. Every run removes them before applying what you asked for, so a tracer left by an earlier release or another tool is replaced rather than left running alongside the new one. Use different names and paths for anything of your own, and the command reports when it replaces something it did not write.
70
+
71
+ | Resource | Name or path |
72
+ | ----------- | --------------------------------------- |
73
+ | Container | `datadog-tracer` |
74
+ | Volume | `datadog-tracer` |
75
+ | Mount paths | `/datadog-lib`, `/opt/datadog-packages` |
76
+
77
+ You can use any nonempty `--language` value without `--tracing inject` to set `DD_SOURCE` for log parsing.
78
+
79
+ The Agent sidecar accepts custom metrics over DogStatsD: `DD_DOGSTATSD_ORIGIN_DETECTION` and `DD_DOGSTATSD_ORIGIN_DETECTION_CLIENT` are turned on and `DD_DOGSTATSD_TAG_CARDINALITY` is set to `orchestrator`, so your metrics are tagged with the task that submitted them. These are filled in the same way, so a task definition that already sets them keeps its own values.
80
+
81
+ Running the command twice is safe: the sidecars are matched by name, so an already instrumented task definition is reported as such and no revision is registered. Each revision the command registers is tagged `dd_sls_ci` with the version of `datadog-ci` that created it. Upgrading the CLI does not on its own produce a new revision, since that tag is not part of the comparison.
82
+
83
+ #### Collecting logs
84
+
85
+ Pass `--log-collection` to send the task's logs to Datadog. A `datadog-log-router` sidecar running [AWS for Fluent Bit](https://github.com/aws/aws-for-fluent-bit) is added and the other containers, including the Agent, are routed through it.
86
+ Existing log configurations are replaced. Omitting `--log-collection` on a later run removes the router and the Datadog FireLens configuration it wrote, but does not restore the log configuration it replaced. Windows tasks cannot use this as FireLens is Linux-only.
87
+
88
+ #### Windows tasks
89
+
90
+ Windows task definitions are instrumented the same way, with these differences the command applies after reading the task's `runtimePlatform`:
91
+
92
+ - The Agent runs the `-servercore` build of the image, published as a manifest list so ECS pulls the variant matching your Windows Server version.
93
+ - The Agent container is given `C:\` as its working directory, which it needs and its image does not set.
94
+ - The tracers reach the Agent on the task's loopback address, `127.0.0.1`, because Windows containers cannot share the Unix socket used on Linux. The `dd-sockets` volume is left off, and `--no-agent-socket` makes no difference on a Windows task.
95
+ - The Agent gets no health check, because the probe is a Linux-only shell script. A probe would report the Agent as permanently unhealthy.
96
+
97
+ `--log-collection` is refused because FireLens does not run on Windows. Any `datadog-log-router` sidecar on the task is removed.
98
+
99
+ A run warns when it drops the socket, when it leaves the Agent without a health check, and when it changes what one of your containers waits for, so you can see what it decided.
100
+
101
+ If you pass `--agent-image` for a Windows task, it is used exactly as given, so point it at a `-servercore` tag. Mirroring `public.ecr.aws/datadog/agent:latest` into your own registry gives you the Linux image, which does not start on Windows.
102
+
103
+ #### Deploying the new revision
104
+
105
+ Pass `--ecs-service` for each service that should run the revision the command just registered. Pass `--cluster` if those services are not in the `default` cluster.
106
+
107
+ A service named by its full ARN already names its cluster, so `--cluster` can be left off. Passing a `--cluster` that contradicts the ARN's cluster is an error, not a silent override. A run updates services in a single cluster, so ARNs that name more than one cluster are reported as an error.
108
+
109
+ Each service is matched to the task definition family it currently runs. A run over several task definitions points each service at its own new revision. A service already running the instrumented revision is left alone rather than redeployed. Matching happens before anything is registered, so a service running a family that no `--task-definition` covers is reported without a revision having been registered for it.
110
+
111
+ Updating a service starts an ECS deployment. The command returns as soon as ECS accepts it, and the rollout follows your service's deployment configuration.
112
+
113
+ Because a service is matched by family, a run instruments one revision per family: naming two revisions of the same family, as `--task-definition my-app:3 --task-definition my-app:4` does, is reported rather than leaving the choice of which one to deploy to the order they were passed in.
114
+
115
+ A task definition and the services running it are instrumented and deployed on their own, so a run over several of them reports every problem it hits and still rolls out the ones that worked: a task definition that could not be instrumented leaves its own services alone, and the rest reach their new revision. Tasks you start yourself with `RunTask`, and services you do not name, keep running the revision they were on.
116
+
117
+ ### `uninstrument`
118
+
119
+ **Warning:** The `ecs-fargate uninstrument` command is in beta. It requires you to set `DD_BETA_COMMANDS_ENABLED=1`.
120
+
121
+ Run `datadog-ci ecs-fargate uninstrument` to remove Datadog instrumentation from an ECS Fargate task definition. The command reads the task definitions you name, removes what `instrument` added, and registers the result as a new revision. As with `instrument`, running tasks do not change until the new revision is deployed. Pass `--ecs-service` to have the command update the service for you.
122
+
123
+ ```bash
124
+ export DD_BETA_COMMANDS_ENABLED=1
125
+
126
+ # Revert a task definition
127
+ datadog-ci ecs-fargate uninstrument --task-definition my-app -r us-east-1
128
+
129
+ # Revert several task definitions in one run
130
+ datadog-ci ecs-fargate uninstrument --task-definition my-app --task-definition my-worker -r us-east-1
131
+
132
+ # Revert a task definition and roll the new revision out to the service running it
133
+ datadog-ci ecs-fargate uninstrument --task-definition my-app -r us-east-1 \
134
+ --ecs-service my-app-service --cluster my-cluster
135
+
136
+ # Preview the changes without registering a revision
137
+ datadog-ci ecs-fargate uninstrument --task-definition my-app -r us-east-1 --dry-run
138
+ ```
139
+
140
+ The command removes the `datadog-agent`, `datadog-log-router`, and `datadog-tracer` sidecars, the `dd-sockets` and `datadog-tracer` volumes along with their mounts, every `DD_`-prefixed environment variable and secret from your application containers, tracer startup fragments such as `NODE_OPTIONS`, the `com.datadoghq.tags.service`, `com.datadoghq.tags.env`, and `com.datadoghq.tags.version` Docker labels, and the `service`, `env`, `version`, `dd_sls_ci`, and `dd_sls_injection_mode` tags from the revision. Add `--env-vars` for each variable you wish to be removed too.
141
+
142
+ Running the command twice is safe: a task definition with no Datadog instrumentation to remove is reported as such and no revision is registered.
143
+
144
+ #### Log configurations
145
+
146
+ `--log-collection` replaces each container's log configuration with one routing through `datadog-log-router`. The container's previous configuration is recorded nowhere, so it cannot be put back. Removing the router leaves each container that was routing through Datadog FireLens with no log configuration at all, which the command warns about: add one to the task definition to keep collecting those logs. A FireLens configuration you set up yourself is left alone.
147
+
148
+ ### Configuration
149
+
150
+ #### AWS credentials
151
+
152
+ You must have valid [AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html#envvars-list) configured with access to the ECS actions `ecs:DescribeTaskDefinition`, `ecs:RegisterTaskDefinition`, and `ecs:TagResource`. The last one is required because the new revision is registered with tags: for `instrument`, the ones the task definition already had plus `service`, `env`, `version`, `dd_sls_ci`, and, when a tracer is injected, `dd_sls_injection_mode`; for `uninstrument`, the ones that are left once those five are removed. Deploying with `--ecs-service` also needs `ecs:DescribeServices` and `ecs:UpdateService`.
153
+
154
+ `--profile` uses a named profile from your AWS configuration instead. A profile with an `mfa_serial` is supported: the command asks for the code when it loads the profile.
155
+
156
+ #### Datadog API key
157
+
158
+ Pass `--api-key-secret-arn` with the ARN of an AWS Secrets Manager secret holding your [Datadog API key](https://app.datadoghq.com/organization-settings/api-keys). The Agent reads the key from the secret at runtime, which keeps it out of the task definition. The task's execution role needs `secretsmanager:GetSecretValue` on that secret. ECS resolves secrets through that role, so a task definition with no `executionRoleArn` is reported and left alone rather than turned into a revision whose tasks cannot start.
159
+
160
+ If you do not pass `--api-key-secret-arn`, the command falls back to the `DD_API_KEY` environment variable and writes its value into the task definition in plain text, which it warns about. A key given this way is validated against your Datadog site before anything is registered, and is masked in the diff the command prints.
161
+
162
+ #### Task role
163
+
164
+ The Agent collects ECS task metadata, which is what tags your telemetry with the task, container, and image it came from. It reads that from the ECS API as the task role, so give the task definition a `taskRoleArn` whose policy allows `ecs:ListClusters`, `ecs:ListContainerInstances`, and `ecs:DescribeContainerInstances`. The command does not change your task role, so it reports a task definition that has none.
165
+
166
+ #### Environment variables
167
+
168
+ - `DD_BETA_COMMANDS_ENABLED`: set to `1` to enable these commands while they are in beta.
169
+ - `DD_API_KEY` (or `DATADOG_API_KEY`): the Datadog API key to write into the task definition, used by `instrument` only when `--api-key-secret-arn` is not passed.
170
+ - `DD_SITE` (or `DATADOG_SITE`): the [Datadog site](https://docs.datadoghq.com/getting_started/site/) to send data to. Defaults to `datadoghq.com`.
171
+ - `AWS_REGION` (or `AWS_DEFAULT_REGION`): the region to use when `--region` is not passed.
172
+
173
+ ### Arguments
174
+
175
+ `--fips` and `--fips-ignore-error` are also accepted, as they are on every command.
176
+
177
+ #### `instrument`
178
+
179
+ <!-- BEGIN_USAGE:instrument -->
180
+ | Argument | Shorthand | Description | Default |
181
+ | -------- | --------- | ----------- | ------- |
182
+ | `--dry` or `--dry-run` | `-d` | Preview the changes the command would apply | `false` |
183
+ | `--task-definition` or `--taskDefinition` | | The family, family:revision, or ARN of the task definition. Can be specified multiple times. | |
184
+ | `--region` | `-r` | The AWS region the task definition lives in | |
185
+ | `--profile` | | Specify the AWS named profile credentials to use. See the AWS CLI documentation on named profiles: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html | |
186
+ | `--ecs-service` or `--ecsService` | | The name of an ECS service to update to the newly registered revision, so that the change rolls out without a manual deployment. Can be specified multiple times. | |
187
+ | `--cluster` | | The ECS cluster the services named by `--ecs-service` run in. Not needed when those are full ARNs, which name their own cluster. Omit it for the `default` cluster of the region. | |
188
+ | `--config` | | Path to the configuration file. | |
189
+ | `--api-key-secret-arn` or `--apiKeySecretArn` | | The ARN of the AWS Secrets Manager secret holding your Datadog API key. Preferred over `DD_API_KEY`, which is written to the task definition in plain text. | |
190
+ | `--agent-image` or `--sidecar-image` | | Override to pin a specific version tag or to use a mirrored image from a custom registry (for example, ECR) to avoid pull rate limits. | `public.ecr.aws/datadog/agent:latest` |
191
+ | `--no-agent-socket` | | Have the tracers reach the Agent over the task loopback address instead of the Unix socket they use by default. Windows tasks always use the loopback address. | |
192
+ | `--log-collection` or `--logCollection` | | Send the task's logs to Datadog. Replaces each container's existing log configuration. Not supported on Windows. | |
193
+ | `--service` | | The value for the service tag. Use this to group related tasks belonging to similar workloads. For example, `my-service`. If not provided, the task definition family is used. | |
194
+ | `--env` or `--environment` | | The value for the env tag. Use this to separate your staging, development, and production environments. For example, `prod`. | |
195
+ | `--version` | | The value for the version tag. Use this to correlate spikes in latency, load, or errors to new versions. For example, `1.0.0`. | |
196
+ | `--extra-tags` or `--extraTags` | | Additional tags to add to the task in the format "key1:value1,key2:value2". | |
197
+ | `--env-vars` | `-e` | Additional environment variables to set on the application containers and the Datadog Agent. Can specify multiple variables in the format `--env-vars VAR1=VALUE1 --env-vars VAR2=VALUE2`. | |
198
+ | `--source-code-integration` or `--sourceCodeIntegration` | | Whether to enable the Datadog Source Code integration. This tags your services with the Git repository and the latest commit hash of the local directory. Specify `--no-source-code-integration` to disable. | `true` |
199
+ | `--upload-git-metadata` or `--uploadGitMetadata` | | Whether to enable Git metadata uploading, as a part of the source code integration. Git metadata uploading is only required if you don't have the Datadog GitHub integration installed. Specify `--no-upload-git-metadata` to disable. | `true` |
200
+ | `--tracing` | | Configure APM instrumentation. Use `manual` when the tracer is installed, `inject` to detect the language and add a tracer automatically, or `disabled` to turn tracing off. Add `--language` with `inject` to select one tracer. Defaults to `manual`. | |
201
+ | `--language` | | Set the application language for log parsing. With `--tracing inject`, this selects one tracer instead of detecting the language automatically. Supported injection values: `java`, `nodejs`, `csharp`, `python`, `ruby`, `php`. `dotnet` is accepted as an alias for `csharp`. | |
202
+ | `--tracer-version` | | Set the tracer image tag. Requires `--tracing inject --language`. | `latest` |
203
+ | `--tracer-libc` | | Set the C standard library used by the application image. Requires `--tracing inject --language`. Possible values: "glibc", "musl". | `glibc` |
204
+ | `--container-name` | | Select the application container to instrument when the task definition has several. Only applies with `--tracing inject`. | |
205
+ | `--log-level` or `--logLevel` | | Specify your Datadog log level. | |
206
+ | `--appsec` | | Enable Application Security Monitoring for the instrumented task. | `false` |
207
+ | `--llmobs` | | If specified, enables LLM Observability for the instrumented task with the provided ML application name. | |
208
+ <!-- END_USAGE:instrument -->
209
+
210
+ #### `uninstrument`
211
+
212
+ <!-- BEGIN_USAGE:uninstrument -->
213
+ | Argument | Shorthand | Description | Default |
214
+ | -------- | --------- | ----------- | ------- |
215
+ | `--dry` or `--dry-run` | `-d` | Preview the changes the command would apply | `false` |
216
+ | `--task-definition` or `--taskDefinition` | | The family, family:revision, or ARN of the task definition. Can be specified multiple times. | |
217
+ | `--region` | `-r` | The AWS region the task definition lives in | |
218
+ | `--profile` | | Specify the AWS named profile credentials to use. See the AWS CLI documentation on named profiles: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html | |
219
+ | `--ecs-service` or `--ecsService` | | The name of an ECS service to update to the newly registered revision, so that the change rolls out without a manual deployment. Can be specified multiple times. | |
220
+ | `--cluster` | | The ECS cluster the services named by `--ecs-service` run in. Not needed when those are full ARNs, which name their own cluster. Omit it for the `default` cluster of the region. | |
221
+ | `--config` | | Path to the configuration file. | |
222
+ | `--env-vars` | `-e` | Additional environment variables to remove from every container in the task. The Datadog ones are removed either way. Can specify multiple variables in the format `--env-vars VAR1=VALUE1 --env-vars VAR2=VALUE2`. | |
223
+ <!-- END_USAGE:uninstrument -->
224
+
225
+ ### Configuration file
226
+
227
+ Instead of supplying arguments, you can create a configuration file in your project and run `datadog-ci ecs-fargate instrument --config datadog-ci.json`. A `datadog-ci.json` in the working directory is picked up automatically, without `--config`. Arguments you pass on the command line override the values in the configuration file. Both commands read the same file, and `uninstrument` ignores the keys that only apply to instrumenting.
228
+
229
+ ```json
230
+ {
231
+ "ecsFargate": {
232
+ "taskDefinitions": ["my-app", "my-worker"],
233
+ "region": "us-east-1",
234
+ "ecsServices": ["my-app-service", "my-worker-service"],
235
+ "cluster": "my-cluster",
236
+ "apiKeySecretArn": "arn:aws:secretsmanager:us-east-1:123456789012:secret:dd-api-key",
237
+ "service": "my-service",
238
+ "environment": "prod",
239
+ "version": "1.0.0",
240
+ "extraTags": "team:backend,project:api",
241
+ "envVars": ["CUSTOM_VAR1=value1", "CUSTOM_VAR2=value2"],
242
+ "logCollection": true,
243
+ "tracing": "inject",
244
+ "language": "nodejs"
245
+ }
246
+ }
247
+ ```
248
+
249
+ Keys name the setting rather than the argument, so a flag that turns something off is the setting set to `false`: `--no-agent-socket` is `"agentSocket": false`.
250
+
251
+ ## Community
252
+
253
+ For product feedback and questions, join the `#serverless` channel in the [Datadog community on Slack](https://chat.datadoghq.com/).