Skip to content

Commit cd50c13

Browse files
Merge pull request #125 from bschaatsbergen/add-checkov
feat: add checkov
2 parents ff6ec11 + 43c7670 commit cd50c13

File tree

3 files changed

+60
-8
lines changed

3 files changed

+60
-8
lines changed

.github/workflows/pre-commit.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: precommit
2+
on:
3+
pull_request:
4+
permissions:
5+
contents: read
6+
defaults:
7+
run:
8+
shell: bash
9+
jobs:
10+
precommit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.8
18+
- name: Create virtual environment
19+
run: python3 -m venv venv && source venv/bin/activate
20+
- name: Install pre-commit and checkov
21+
run: |
22+
python3 -m pip install --upgrade pip
23+
python3 -m pip install pre-commit==3.5.0 checkov==2.5.10
24+
- name: install terraform-docs
25+
run: |
26+
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz
27+
tar -xzf terraform-docs.tar.gz
28+
chmod +x terraform-docs
29+
mv terraform-docs /usr/local/bin/
30+
- name: Cache packages
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/.cache/pip
34+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
35+
restore-keys: |
36+
${{ runner.os }}-pip-
37+
- name: Run pre-commit
38+
run: pre-commit run --show-diff-on-failure --color=always --all-files

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
33
rev: v1.74.1
44
hooks:
5+
- id: terraform_checkov
6+
args:
7+
- --args=--quiet
8+
- --args=--compact
9+
- --args=--framework=terraform
10+
- --args=--skip-check=CKV_TF_1,CKV_GCP_32,CKV_GCP_34,CKV2_GCP_18
511
- id: terraform_fmt
612
exclude: ^examples/
713
- id: terraform_validate

examples/complete/main.tf

+16-8
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@ resource "google_project_iam_member" "atlantis_metric_writer" {
3333
}
3434

3535
resource "google_compute_network" "default" {
36-
name = "example-network"
37-
auto_create_subnetworks = false
38-
project = local.project_id
36+
name = "example-network"
37+
auto_create_subnetworks = false
38+
project = local.project_id
3939
}
4040

4141
resource "google_compute_subnetwork" "default" {
42-
name = "example-subnetwork"
43-
ip_cidr_range = "10.2.0.0/16"
44-
region = local.region
45-
network = google_compute_network.default.id
46-
project = local.project_id
42+
name = "example-subnetwork"
43+
ip_cidr_range = "10.2.0.0/16"
44+
region = local.region
45+
network = google_compute_network.default.id
46+
project = local.project_id
47+
private_ip_google_access = true
48+
private_ipv6_google_access = "ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE"
49+
50+
log_config {
51+
aggregation_interval = "INTERVAL_5_SEC"
52+
flow_sampling = 0.5
53+
metadata = "INCLUDE_ALL_METADATA"
54+
}
4755
}
4856

4957
# Create a router, which we associate the Cloud NAT too

0 commit comments

Comments
 (0)