|
| 1 | +--- |
| 2 | +title: Setup App and API Protection for Java on AWS Fargate |
| 3 | +further_reading: |
| 4 | +- link: "/security/application_security/how-it-works/" |
| 5 | + tag: "Documentation" |
| 6 | + text: "How App and API Protection Works" |
| 7 | +- link: "/security/default_rules/?category=cat-application-security" |
| 8 | + tag: "Documentation" |
| 9 | + text: "OOTB App and API Protection Rules" |
| 10 | +- link: "/security/application_security/troubleshooting" |
| 11 | + tag: "Documentation" |
| 12 | + text: "Troubleshooting App and API Protection" |
| 13 | +--- |
| 14 | + |
| 15 | +{{< partial name="api_security/java/callout.html" >}} |
| 16 | + |
| 17 | +{{< partial name="api_security/java/overview.html" >}} |
| 18 | + |
| 19 | +This guide explains how to set up App and API Protection (AAP) for Java applications running on AWS Fargate. The setup involves: |
| 20 | +1. Installing the Datadog Agent |
| 21 | +2. Configuring your Java application |
| 22 | +3. Enabling AAP monitoring |
| 23 | + |
| 24 | +## Prerequisites |
| 25 | + |
| 26 | +- AWS Fargate environment |
| 27 | +- Java application containerized with Docker |
| 28 | +- AWS CLI configured with appropriate permissions |
| 29 | +- Datadog Agent installed |
| 30 | + |
| 31 | +## Setup |
| 32 | + |
| 33 | +### 1. Install the Datadog Agent |
| 34 | + |
| 35 | +Install the Datadog Agent in your Fargate task definition: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "containerDefinitions": [ |
| 40 | + { |
| 41 | + "name": "datadog-agent", |
| 42 | + "image": "public.ecr.aws/datadog/agent:latest", |
| 43 | + "environment": [ |
| 44 | + { |
| 45 | + "name": "DD_API_KEY", |
| 46 | + "value": "<YOUR_API_KEY>" |
| 47 | + }, |
| 48 | + { |
| 49 | + "name": "DD_APM_ENABLED", |
| 50 | + "value": "true" |
| 51 | + }, |
| 52 | + { |
| 53 | + "name": "DD_APM_NON_LOCAL_TRAFFIC", |
| 54 | + "value": "true" |
| 55 | + } |
| 56 | + ] |
| 57 | + } |
| 58 | + ] |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +## Library setup |
| 63 | + |
| 64 | +To enable AAP capabilities, you need the Datadog Java tracing library (version 0.94.0 or higher) installed in your application environment. |
| 65 | + |
| 66 | +### Download the library |
| 67 | + |
| 68 | +Add the following to your application's Dockerfile: |
| 69 | + |
| 70 | +```dockerfile |
| 71 | +ADD 'https://dtdg.co/latest-java-tracer' /dd-java-agent.jar |
| 72 | +``` |
| 73 | + |
| 74 | +### Verify compatibility |
| 75 | + |
| 76 | +To check that your service's language and framework versions are supported for AAP capabilities, see [Single Step Instrumentation Compatibility][2]. |
| 77 | + |
| 78 | +## Service configuration |
| 79 | + |
| 80 | +### Standalone billing alternative |
| 81 | + |
| 82 | +If you want to use Application Security Management without APM tracing functionality, you can deploy with [Standalone App and API Protection][4]. This configuration reduces the amount of APM data sent to Datadog to the minimum required by App and API Protection products. |
| 83 | + |
| 84 | +To enable standalone mode: |
| 85 | +1. Set `DD_APM_TRACING_ENABLED=false` environment variable |
| 86 | +2. Keep `DD_APPSEC_ENABLED=true` environment variable |
| 87 | +3. This configuration will minimize APM data while maintaining full security monitoring capabilities |
| 88 | + |
| 89 | +### Enabling AAP |
| 90 | + |
| 91 | +#### Run your application with AAP enabled |
| 92 | + |
| 93 | +Update your task definition to include the Java agent and AAP configuration: |
| 94 | + |
| 95 | +```json |
| 96 | +{ |
| 97 | + "containerDefinitions": [ |
| 98 | + { |
| 99 | + "name": "your-java-app", |
| 100 | + "image": "your-java-app-image", |
| 101 | + "environment": [ |
| 102 | + { |
| 103 | + "name": "DD_APPSEC_ENABLED", |
| 104 | + "value": "true" |
| 105 | + }, |
| 106 | + { |
| 107 | + "name": "DD_SERVICE", |
| 108 | + "value": "<YOUR_SERVICE_NAME>" |
| 109 | + }, |
| 110 | + { |
| 111 | + "name": "DD_ENV", |
| 112 | + "value": "<YOUR_ENVIRONMENT>" |
| 113 | + } |
| 114 | + ], |
| 115 | + "command": [ |
| 116 | + "java", |
| 117 | + "-javaagent:/dd-java-agent.jar", |
| 118 | + "-jar", |
| 119 | + "/app.jar" |
| 120 | + ] |
| 121 | + } |
| 122 | + ] |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +**Important considerations:** |
| 127 | +- **File system requirements**: Read-only file systems are not currently supported. The application must have access to a writable `/tmp` directory. |
| 128 | +- **Service identification**: Always specify `DD_SERVICE` (or `-Ddd.service`) and `DD_ENV` (or `-Ddd.env`) for proper service identification in Datadog. |
| 129 | + |
| 130 | +## Verify setup |
| 131 | + |
| 132 | +To verify that AAP is working correctly: |
| 133 | + |
| 134 | +1. Send some traffic to your application |
| 135 | +2. Check the [Application Signals Explorer][2] in Datadog |
| 136 | +3. Look for security signals and vulnerabilities |
| 137 | + |
| 138 | +## Troubleshooting |
| 139 | + |
| 140 | +If you encounter issues while setting up App and API Protection for your Java application, see the [Java App and API Protection troubleshooting guide][3]. |
| 141 | + |
| 142 | +## Further Reading |
| 143 | + |
| 144 | +{{< partial name="whats-next/whats-next.html" >}} |
| 145 | + |
| 146 | +[1]: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/single-step-apm/?tab=awsfargate |
| 147 | +[2]: https://app.datadoghq.com/security/appsec |
| 148 | +[3]: /security/application_security/setup/java/troubleshooting |
| 149 | +[4]: /security/application_security/setup/java/standalone |
0 commit comments