GitLab IaC Scanning for Terraform Prompt
Enable GitLab Infrastructure-as-Code (IaC) scanning to catch insecure Terraform, CloudFormation, and Kubernetes manifests in merge requests before they apply.
- Target user
- platform engineers maintaining GitLab pipelines and Terraform modules
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform-security engineer who has rolled out GitLab IaC Scanning (KICS-based) across Terraform and Kubernetes monorepos. I will provide: - The IaC types and layout in my repo (Terraform modules, Helm charts, raw k8s YAML, CloudFormation) and directory structure - My current `.gitlab-ci.yml` and whether SAST is already included - My tolerance for findings (block on Critical/High, warn on the rest) and any known false positives Your job: 1. **Enable the scanner** — produce the `include:` for the SAST template and the variables that activate the IaC/KICS analyzer for my file types. 2. **Scope the scan** — set `SAST_EXCLUDED_PATHS` and analyzer rules so generated, vendored, or example directories are skipped without hiding real config. 3. **Wire MR gating** — show how findings surface in the MR security widget and how to fail the pipeline above a chosen severity using a Scan Result Policy or a `rules`-based gate. 4. **Tune false positives** — explain inline rule suppression vs. a vulnerability dismissal trail, and when each is appropriate. 5. **Map common Terraform findings** — list the high-value checks (public S3/storage, open security groups, unencrypted volumes, hardcoded secrets) and the safe remediation for each. 6. **Avoid drift gaps** — clarify that IaC scanning checks code, not deployed state, and where a separate posture/CSPM scan is still needed. 7. **Validate** — give a test MR that introduces an open `0.0.0.0/0` ingress and confirm it is flagged and blocked. Output as: a fenced `.gitlab-ci.yml` snippet, a severity-to-action table, and a top-10 Terraform findings remediation list. Remember that IaC scanning evaluates source files only — a clean scan does not mean the running infrastructure is compliant if it has drifted or was changed out of band.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
GitLab CI/CD FIPS-Compliant Runner Hardening Prompt
Stand up and validate FIPS 140-compliant GitLab Runners and pipelines — FIPS images, crypto policy, verification, and avoiding silent non-compliant fallbacks.
-
GitLab API Fuzzing Scan Profile Prompt
Stand up GitLab API Fuzzing against a REST/GraphQL service in CI using an OpenAPI or HAR spec, with tuned scan profiles and authenticated sessions.
-
GitLab CI Job Token Scope Allowlist Prompt
Lock down the GitLab CI/CD job token (CI_JOB_TOKEN) with a project access allowlist so pipelines can only reach explicitly trusted projects, closing cross-project token abuse.
-
GitLab License Scanning Policy Gate Prompt
Configure GitLab license compliance scanning and a merge-request approval policy that blocks denied open-source licenses before they reach the default branch.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.