Skip to content

Commit e3c7d29

Browse files
valeryjulimaycmlee
andauthored
chore(k9-iac): Add IaC CI setup doc (#39321)
* Add IaC CI setup doc * Fix heading capitalization and variable name mismatch in IaC CI setup doc * Apply word-list and sentence-length fixes to IaC CI setup doc * Update from feedback on iac-setup * Update hugo/content/en/security/code_security/iac_security/setup.md Co-authored-by: May Lee <may.lee@datadoghq.com> --------- Co-authored-by: May Lee <may.lee@datadoghq.com>
1 parent 8605055 commit e3c7d29

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

  • hugo/content/en/security/code_security/iac_security

hugo/content/en/security/code_security/iac_security/setup.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,57 @@ After setting up the Azure DevOps integration, enable IaC Security for your repo
9494
{{% /tab %}}
9595
{{< /tabs >}}
9696

97+
## Set up IaC with a generic CI provider
98+
99+
### Overview
100+
101+
If you don't use GitHub Actions, GitLab CI/CD, or Azure DevOps, you can run the [Datadog IaC Scanner][8] directly in your CI pipeline. Upload IaC scan results to Datadog using the [`datadog-ci` CLI][9].
102+
103+
**If you are running IaC Security on a non-GitHub repository**, run the first scan on your default branch. If your default branch uses a name other than `master`, `main`, `default`, `stable`, `source`, `prod`, or `develop`, upload a first scan for your repository. Then, manually override the default branch in [{{< ui >}}Repository Settings{{< /ui >}}][10] so that future scans from non-default branches are uploaded and correctly processed.
104+
105+
### Prerequisites
106+
107+
- Node.js 20 or later and npm
108+
- `curl`
109+
- `tar`
110+
- Permission to install the scanner in `/usr/local/bin`
111+
112+
Configure the following environment variables:
113+
114+
| Name | Description | Required | Default |
115+
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------- |
116+
| `DD_API_KEY` | Your Datadog API key. Create this key in your [Datadog organization][4] and store the key as a secret. | Yes | |
117+
| `DD_APP_KEY` | Your application key. Create this key in your [Datadog organization][4] and include the `code_analysis_read` scope. Store the key as a secret. | Yes | |
118+
| `DD_SITE` | The [Datadog site][5] to send information to. Your Datadog site is `datadoghq.com`. | No | `datadoghq.com` |
119+
120+
Add the following to your CI pipeline:
121+
122+
```bash
123+
# Set the Datadog site to send information to
124+
export DD_SITE="datadoghq.com"
125+
126+
# Install dependencies
127+
npm install -g @datadog/datadog-ci
128+
129+
# Download the latest Datadog IaC Scanner (x86_64/amd64 Linux; see GitHub Releases for arm64 and other platforms)
130+
export IAC_SCANNER_URL="https://github.com/DataDog/datadog-iac-scanner/releases/latest/download/datadog-iac-scanner_linux_amd64.tar.gz"
131+
curl -L "${IAC_SCANNER_URL}" -o /tmp/datadog-iac-scanner.tar.gz
132+
tar xfz /tmp/datadog-iac-scanner.tar.gz -C /tmp
133+
mv /tmp/datadog-iac-scanner /usr/local/bin/datadog-iac-scanner
134+
135+
# Run the Datadog IaC scanner
136+
exit_code=0
137+
/usr/local/bin/datadog-iac-scanner scan -p . -o /tmp || exit_code=$?
138+
if [ $exit_code -lt 20 -o $exit_code -gt 60 ]; then echo "IaC scan failed" ; exit $exit_code ; fi
139+
140+
# Upload results
141+
datadog-ci sarif upload /tmp/datadog-iac-scanner-result.sarif
142+
```
143+
144+
<div class="alert alert-info">
145+
This example uses the x86_64 (amd64) Linux version of the Datadog IaC Scanner. The scanner also supports arm64 Linux, as well as macOS and Windows. If you're using a different OS or architecture, select the appropriate release from the <a href="https://github.com/DataDog/datadog-iac-scanner/releases">GitHub Releases</a> page and update the <code>IAC_SCANNER_URL</code> value.
146+
</div>
147+
97148
## Upload third-party static analysis results to IaC Security
98149

99150
<div class="alert alert-info">
@@ -149,3 +200,6 @@ To ensure proper ingestion and display in Datadog IaC Scanning for third-party s
149200
[5]: /getting_started/site/
150201
[6]: https://docs.datadoghq.com/security/code_security/static_analysis/setup/?tab=github#upload-third-party-static-analysis-results-to-datadog
151202
[7]: https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=sarif
203+
[8]: https://github.com/DataDog/datadog-iac-scanner
204+
[9]: https://github.com/DataDog/datadog-ci?tab=readme-ov-file#sarif
205+
[10]: https://app.datadoghq.com/source-code/repositories

0 commit comments

Comments
 (0)