From harness-claude
Analyzes Terraform, CloudFormation, and Pulumi IaC for module structure, state management, drift prevention, and security posture. Use when reviewing configs, auditing modules, or PRs adding cloud resources.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Terraform, CloudFormation, and Pulumi analysis. Module structure, state management, drift prevention, and security posture for infrastructure definitions.
Provides expert IaC automation guidance for Terraform, Pulumi, CloudFormation in AWS, GCP, Azure. Covers state management, drift detection, modules, workspaces, plans, and production safeguards.
Validates IaC using Terraform, CloudFormation, Pulumi, CDK: runs validation, security policy checks, Infracost cost estimation, and drift detection. Activates on terraform plan or infrastructure review.
Implements IaC security scanning with Checkov, tfsec, KICS for Terraform, CloudFormation, Kubernetes manifests, and Helm charts; integrates into CI/CD to block misconfigurations.
Share bugs, ideas, or general feedback.
Terraform, CloudFormation, and Pulumi analysis. Module structure, state management, drift prevention, and security posture for infrastructure definitions.
Detect IaC tooling. Scan the project for infrastructure definitions:
*.tf files -- Terraform (HCL)terraform/ directory with .terraform.lock.hclcloudformation/, *.template.yaml, *.template.json -- CloudFormationPulumi.yaml, Pulumi.*.yaml -- Pulumicdk.json, cdk.out/ -- AWS CDKinfrastructure/, infra/ -- common IaC directoriesIdentify provider and backend. Parse configuration for:
Map module structure. Build a dependency tree of modules:
Detect environment separation. Identify how environments are managed:
environments/dev/, environments/prod/)terraform.tfvars, prod.tfvars)Present detection summary:
IaC Detection:
Tool: Terraform v1.7
Provider: AWS (us-east-1, us-west-2)
Backend: S3 with DynamoDB locking
Modules: 8 local, 3 registry
Environments: dev, staging, prod (directory-per-env)
State files: 3 (one per environment)
Check state management. Verify state is properly configured:
Evaluate module design. Check modules for:
Check resource naming and tagging. Verify:
{project}-{env}-{resource})Analyze dependency management. Check for:
Check for common anti-patterns:
Recommend module decomposition. If monolithic configurations are detected:
Design state management strategy. Recommend:
terraform_remote_state or SSM parametersRecommend drift detection workflow. Design a process to catch manual changes:
terraform plan in CI to detect driftDesign environment promotion. Recommend a workflow for infrastructure changes:
Recommend security hardening. For each provider:
sensitive = trueRun static analysis. Execute available validation tools:
terraform validate, terraform fmt -checkcfn-lint or aws cloudformation validate-templatecdk synth to verify template generationtflint, checkov, or tfsec for security checksVerify variable completeness. For each root module:
any)Check plan safety. If a plan output is available:
prevent_destroyVerify security posture. Run security-focused checks:
Generate validation report:
IaC Validation: [PASS/WARN/FAIL]
Format check: PASS (all files formatted)
Validate: PASS (no syntax errors)
Security scan: WARN (2 findings)
- modules/storage/main.tf: S3 bucket missing server-side encryption
- modules/network/main.tf: security group allows 0.0.0.0/0 on port 22
Module design: WARN (3 modules missing input validation)
State management: PASS (remote backend with locking)
Recommendations:
1. Add aws_s3_bucket_server_side_encryption_configuration resource
2. Restrict SSH access to VPN CIDR range
3. Add variable validation blocks to network, compute, and storage modules
harness skill run harness-infrastructure-as-code -- Primary invocation for IaC analysis.harness validate -- Run after configuration changes to verify project health.harness check-deps -- Verify IaC tool dependencies are installed.emit_interaction -- Present design recommendations and gather decisions on module structure.Phase 1: DETECT
Tool: Terraform v1.6.4
Provider: AWS (hashicorp/aws ~> 5.0)
Backend: S3 (us-east-1) with DynamoDB locking
Modules: 5 local (vpc, ecs, rds, s3, iam), 2 registry (datadog, cloudwatch)
Environments: dev, staging, prod (directory-per-env with shared modules)
Phase 2: ANALYZE
State management: PASS (remote, encrypted, locked, per-env)
Module design: WARN
- modules/ecs has 450 lines -- recommend splitting into ecs-cluster
and ecs-service modules
- modules/rds missing variable validation for instance_class
Naming: PASS (consistent {project}-{env}-{resource} pattern)
Tags: WARN (cost-center tag missing on 3 resources)
Anti-patterns: 1 hardcoded AMI in modules/ecs/main.tf
Phase 3: DESIGN
1. Split modules/ecs into ecs-cluster and ecs-service
2. Add data source for AMI lookup instead of hardcoded value
3. Add variable validation: instance_class must be db.t3.* or db.r6g.*
4. Add cost-center tag to default_tags in provider configuration
5. Add scheduled terraform plan for drift detection in CI
Phase 4: VALIDATE
terraform fmt: PASS
terraform validate: PASS
tfsec: WARN (2 findings -- see above)
checkov: PASS
Result: WARN -- 5 improvements recommended, no blocking issues
Phase 1: DETECT
Tool: AWS CDK v2.120 (TypeScript)
Provider: AWS (us-west-2)
Backend: CloudFormation (managed by CDK)
Stacks: 3 (NetworkStack, ComputeStack, StorageStack)
Environments: dev and prod via CDK context
Phase 2: ANALYZE
Stack design: PASS (clean separation by concern)
Cross-stack references: PASS (using CfnOutput and Fn::ImportValue)
Security: WARN
- ComputeStack: EC2 instance has public IP and open SSH
- StorageStack: DynamoDB table missing point-in-time recovery
CDK constructs: Using L2 constructs (good -- higher abstraction)
Phase 3: DESIGN
1. Add bastion host pattern instead of direct SSH to EC2
2. Enable point-in-time recovery on DynamoDB table
3. Add cdk-nag for automated security checks in synthesis
4. Add stack-level tags via Tags.of(stack).add()
Phase 4: VALIDATE
cdk synth: PASS (3 templates generated)
cfn-lint: PASS (all templates valid)
Security: WARN (2 findings)
Result: WARN -- 2 security improvements needed
| Rationalization | Reality |
|---|---|
| "We store state locally because it's just a dev environment" | Local state is not shared between team members. Two developers running terraform apply against the same environment with diverged local state will produce conflicting resource definitions, duplicate resources, or state corruption that requires manual recovery. |
| "We haven't pinned the provider version because we want to automatically get security patches" | Unpinned providers can silently change resource behavior on terraform init. A ~> 5.0 constraint without an upper bound can pull a provider with breaking changes. Pin the minor version and upgrade explicitly via reviewed PRs so changes are intentional. |
| "That S3 bucket has public access because it hosts our static site" | Static site hosting does not require a public bucket ACL. CloudFront with an Origin Access Control (OAC) policy serves files from a private bucket. Public bucket ACLs are a common misconfiguration vector because they apply to all objects, including accidentally uploaded sensitive files. |
| "We'll tag resources properly before we go to production" | Untagged resources accumulate. Cost allocation reports become impossible, security audits cannot identify owners, and decommissioning requires manual investigation of every resource. Tagging must be enforced at resource creation — retroactive tagging at scale is a weeks-long engineering project. |
| "Manual changes are fine for urgent hotfixes — we'll import them to Terraform afterward" | Manual changes without immediate import create drift that may be overwritten by the next terraform apply. The "import it later" step is almost never done. Every manual change that goes unimported erodes the reliability guarantee that IaC provides. |
>= without an upper bound or omitting version constraints entirely is a blocking finding.terraform state pull for backup, and advise manual reconciliation with a plan review before any apply.terraform import commands for each resource and note that import does not generate configuration -- the HCL must be written manually..terraform-version (tfenv) or Pulumi.yaml and adding version checks to CI.