| marp | true |
|---|---|
| theme | custom-default |
| footer | https://chris-ayers.com |
BlueSky: @chris-ayers.com
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes
Mastodon: @Chrisayers@hachyderm.io
Twitter: @Chris_L_Ayers
- What is Infrastructure as Code (IaC)?
- Security Tooling
- Rules & Customization
- Workflow
- Integration
- Precommit hook
- VSCode Integration
- GitHub Actions
Infrastructure as code (IaC) is a way to manage and provision infrastructure resources using configuration files and automation tools.
The goal of IaC is to make it easier to deploy and manage infrastructure in a repeatable, reliable way, and to reduce the risk of errors caused by manual configuration.
There have been multiple breaches and attacks due to misconfiguration. Vulnerabilities can be a simple omitted property.
Source: The State of Cloud Security 2021 Report
We can't just do security in production after everything is built, we need to go into solutions with security baked in.
Running security testing tools against infrastructure as code (IaC) is a way to ensure that the infrastructure being provisioned is secure and compliant with best practices.
<style scoped>li { list-style-type: none}</style>
SAST is a method of debugging that is performed by looking at the source code of an application without actually executing the application.
Each of these tools does similar things and are SAST (Static Analysis Security Tooling). With Terraform you can analyze in a few ways.
- HCL files
- Terraform Plan
There are many open-source tools as well as commercial solutions. We can integrate these tools in our local environments as well as our pipelines to secure things earlier.
| Feature | tfsec | terrascan | checkov |
|---|---|---|---|
| CI/CD | Yes | Yes | Yes |
| Rules | 100+ | 100+ | 100+ |
| Custom Rules | Yes | Yes | Yes |
| Rule Language | json, yaml, rego | rego | python |
- Ignoring rules
- Overriding rules
- Add custom rules
<style> @media print { section.tfsec-demo figure { background-image: url("./img/tfsec-demo-print.png") !important; } } </style>
tfsec is a static analysis security scanner for your Terraform code supported by Aquasecurity.
Designed to run locally and in your CI pipelines, developer-friendly output and fully documented checks.
- OPA/Rego Policies
- VS Code Extension
- GitHub Actions
Terrascan has support for Terraform, Azure, GCP, AWS, Kubernetes (manifests, Helm, Kustomize), Docker and even GitHub. Supported by Tenable and now integrated into nessus.
Terrascan has a large number of built in policies as well as support for custom OPA/Rego Policies.
Checkov is another tool that lets us do scanning and compliance.
Checkov is by BridgeCrew and python based. Checkov, like terrascan, supports Terraform, Azure, GCP, AWS, Kubernetes (manifests, Helm, Kustomize) and Docker.
Bonus Tool - Yor
- Tagging: Automates tagging in IaC for better resource traceability.
- Context: Provides enriched data on resource deployment.
- CI/CD Integration: Facilitates automated tagging at scale.
Bonus Tool - Atlantis
Terraform PR Automation Handles planning, locking, and applying
Because these tools are independent and all scan the raw HCL or interpreted HCL, you can get different rules and potentially better compliance.
You can also hit a Signal to Noise problem.
- Pre-Commit Hooks
- IDE Integration
- CI/CD Integration
Pre-commit Hooks run before code gets committed to a git repo. You do it yourself or use the Pre-Commit Framework.
- GitHub Marketplace Extensions
- AzureRM
- Terraform on Azure Docs
- Docs for other providers
- Check docs
- Use environment vars
No more passwords Auth is claims based on repo, environment, branch..
BlueSky: @chris-ayers.com
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes
Mastodon: @Chrisayers@hachyderm.io
Twitter: @Chris_L_Ayers















