You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/guides/terraform/checkov.mdx
+56-13Lines changed: 56 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,18 +3,32 @@ description: Use checkov for static analysis of a Nitric project deployed with T
3
3
tags:
4
4
- Terraform
5
5
- Testing
6
-
published_at: 2025-01-16
6
+
published_at: 2025-04-11
7
7
---
8
8
9
9
# Static analysis of Terraform with Checkov
10
10
11
11
This guide will walk you through generating a report with [Checkov](https://www.checkov.io/) from a Nitric project.
12
12
13
-
## How Checkov works
13
+
## What is Checkov?
14
14
15
-
[Checkov](https://www.checkov.io/) is a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations that may lead to security or compliance problems.
15
+
[Checkov](https://www.checkov.io/) is a static code analysis tool for scanning infrastructure as code (IaC) files for misconfigurations. Checkov provides several key benefits for your projects:
16
16
17
-
This guide assumes that you have already [installed Checkov](https://www.checkov.io/1.Welcome/Quick%20Start.html#install-checkov-from-pypi) by following their installation guide.
17
+
-**Security Scanning**: Automatically detects misconfigurations and security vulnerabilities in your infrastructure code before deployment
18
+
-**Compliance**: Helps ensure your infrastructure meets compliance requirements for standards like CIS, HIPAA, and PCI DSS
19
+
-**Best Practices**: Enforces infrastructure best practices and coding standards
20
+
-**Early Detection**: Catches potential issues during development rather than after deployment
21
+
-**Custom Rules**: Allows you to create custom rules specific to your organization's requirements
22
+
23
+
## Prerequisites
24
+
25
+
Before you begin, ensure you have:
26
+
27
+
-[AWS CLI](https://aws.amazon.com/cli/) installed and configured
The Nitric Terraform providers are currently in preview, to enable them you'll need to enable beta-providers in your Nitric project. You can do this by adding the following to your project's nitric.yaml file:
66
-
67
-
```yaml title:nitric.yaml
68
-
preview:
69
-
- beta-providers
70
-
```
71
-
72
79
Once you've created your stack file, you can generate the Terraform code by running the following command:
73
80
74
81
```bash
75
82
nitric up
76
83
```
77
84
78
-
This will generate Terraform code which can deploy your application. The output will be in a folder named cdktf.out by default.
85
+
This will generate Terraform code which can deploy your application. The output will be in a folder named `cdktf.out` by default.
Checkov comes with some great default checks, however, they do need to be aligned with the requirements of your application.
97
129
98
-
For example the Checkov policy ‘CKV_AWS_136‘ checks specifically for SSE-KMS using a customer-managed KMS key (or at least AWS-managed KMS key). This finding might not always be relevant because, by default, Amazon ECR encrypts container images at rest using Amazon S3 server-side encryption (SSE-S3). That means your images are always encrypted, even if you don’t explicitly configure a KMS key.
130
+
For example the Checkov policy `CKV_AWS_136` checks specifically for SSE-KMS using a customer-managed KMS key (or at least AWS-managed KMS key). This finding might not always be relevant because, by default, Amazon ECR encrypts container images at rest using Amazon S3 server-side encryption (SSE-S3). That means your images are always encrypted, even if you don't explicitly configure a KMS key.
131
+
132
+
A way to handle these false positives is to use [suppress/skip comments](https://www.checkov.io/2.Basics/Suppressing%20and%20Skipping%20Policies.html) in the Terraform code.
133
+
134
+
```terraform
135
+
# checkov:skip=CKV_AWS_136
136
+
resource "aws_ecr_repository" "repo" {
137
+
name = "my-ecr-repo"
138
+
}
139
+
```
140
+
141
+
You could also use custom policies to handle these false positives or create custom rules to better match your infrastructure requirements.
99
142
100
143
If you have any concerns, please don't hesitate to [reach out](https://nitric.io/chat).
0 commit comments