@techwavedev/agi-agent-kit 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @techwavedev/agi-agent-kit might be problematic. Click here for more details.
- package/CHANGELOG.md +82 -1
- package/README.md +190 -12
- package/bin/init.js +30 -2
- package/package.json +6 -3
- package/templates/base/AGENTS.md +54 -23
- package/templates/base/README.md +325 -0
- package/templates/base/directives/memory_integration.md +95 -0
- package/templates/base/execution/memory_manager.py +309 -0
- package/templates/base/execution/session_boot.py +218 -0
- package/templates/base/execution/session_init.py +320 -0
- package/templates/base/skill-creator/SKILL_skillcreator.md +23 -36
- package/templates/base/skill-creator/scripts/init_skill.py +18 -135
- package/templates/skills/ec/README.md +31 -0
- package/templates/skills/ec/aws/SKILL.md +1020 -0
- package/templates/skills/ec/aws/defaults.yaml +13 -0
- package/templates/skills/ec/aws/references/common_patterns.md +80 -0
- package/templates/skills/ec/aws/references/mcp_servers.md +98 -0
- package/templates/skills/ec/aws-terraform/SKILL.md +349 -0
- package/templates/skills/ec/aws-terraform/references/best_practices.md +394 -0
- package/templates/skills/ec/aws-terraform/references/checkov_reference.md +337 -0
- package/templates/skills/ec/aws-terraform/scripts/configure_mcp.py +150 -0
- package/templates/skills/ec/confluent-kafka/SKILL.md +655 -0
- package/templates/skills/ec/confluent-kafka/references/ansible_playbooks.md +792 -0
- package/templates/skills/ec/confluent-kafka/references/ec_deployment.md +579 -0
- package/templates/skills/ec/confluent-kafka/references/kraft_migration.md +490 -0
- package/templates/skills/ec/confluent-kafka/references/troubleshooting.md +778 -0
- package/templates/skills/ec/confluent-kafka/references/upgrade_7x_to_8x.md +488 -0
- package/templates/skills/ec/confluent-kafka/scripts/kafka_health_check.py +435 -0
- package/templates/skills/ec/confluent-kafka/scripts/upgrade_preflight.py +568 -0
- package/templates/skills/ec/confluent-kafka/scripts/validate_config.py +455 -0
- package/templates/skills/ec/consul/SKILL.md +427 -0
- package/templates/skills/ec/consul/references/acl_setup.md +168 -0
- package/templates/skills/ec/consul/references/ha_config.md +196 -0
- package/templates/skills/ec/consul/references/troubleshooting.md +267 -0
- package/templates/skills/ec/consul/references/upgrades.md +213 -0
- package/templates/skills/ec/consul/scripts/consul_health_report.py +530 -0
- package/templates/skills/ec/consul/scripts/consul_status.py +264 -0
- package/templates/skills/ec/consul/scripts/generate_values.py +170 -0
- package/templates/skills/ec/documentation/SKILL.md +351 -0
- package/templates/skills/ec/documentation/references/best_practices.md +201 -0
- package/templates/skills/ec/documentation/scripts/analyze_code.py +307 -0
- package/templates/skills/ec/documentation/scripts/detect_changes.py +460 -0
- package/templates/skills/ec/documentation/scripts/generate_changelog.py +312 -0
- package/templates/skills/ec/documentation/scripts/sync_docs.py +272 -0
- package/templates/skills/ec/documentation/scripts/update_skill_docs.py +366 -0
- package/templates/skills/ec/gitlab/SKILL.md +529 -0
- package/templates/skills/ec/gitlab/references/agent_installation.md +416 -0
- package/templates/skills/ec/gitlab/references/api_reference.md +508 -0
- package/templates/skills/ec/gitlab/references/gitops_flux.md +465 -0
- package/templates/skills/ec/gitlab/references/troubleshooting.md +518 -0
- package/templates/skills/ec/gitlab/scripts/generate_agent_values.py +329 -0
- package/templates/skills/ec/gitlab/scripts/gitlab_agent_status.py +414 -0
- package/templates/skills/ec/jira/SKILL.md +484 -0
- package/templates/skills/ec/jira/references/jql_reference.md +148 -0
- package/templates/skills/ec/jira/scripts/add_comment.py +91 -0
- package/templates/skills/ec/jira/scripts/bulk_log_work.py +124 -0
- package/templates/skills/ec/jira/scripts/create_ticket.py +162 -0
- package/templates/skills/ec/jira/scripts/get_ticket.py +191 -0
- package/templates/skills/ec/jira/scripts/jira_client.py +383 -0
- package/templates/skills/ec/jira/scripts/log_work.py +154 -0
- package/templates/skills/ec/jira/scripts/search_tickets.py +104 -0
- package/templates/skills/ec/jira/scripts/update_comment.py +67 -0
- package/templates/skills/ec/jira/scripts/update_ticket.py +161 -0
- package/templates/skills/ec/karpenter/SKILL.md +301 -0
- package/templates/skills/ec/karpenter/references/ec2nodeclasses.md +421 -0
- package/templates/skills/ec/karpenter/references/migration.md +396 -0
- package/templates/skills/ec/karpenter/references/nodepools.md +400 -0
- package/templates/skills/ec/karpenter/references/troubleshooting.md +359 -0
- package/templates/skills/ec/karpenter/scripts/generate_ec2nodeclass.py +187 -0
- package/templates/skills/ec/karpenter/scripts/generate_nodepool.py +245 -0
- package/templates/skills/ec/karpenter/scripts/karpenter_status.py +359 -0
- package/templates/skills/ec/opensearch/SKILL.md +720 -0
- package/templates/skills/ec/opensearch/references/ml_neural_search.md +576 -0
- package/templates/skills/ec/opensearch/references/operator.md +532 -0
- package/templates/skills/ec/opensearch/references/query_dsl.md +532 -0
- package/templates/skills/ec/opensearch/scripts/configure_mcp.py +148 -0
- package/templates/skills/ec/victoriametrics/SKILL.md +598 -0
- package/templates/skills/ec/victoriametrics/references/kubernetes.md +531 -0
- package/templates/skills/ec/victoriametrics/references/prometheus_migration.md +333 -0
- package/templates/skills/ec/victoriametrics/references/troubleshooting.md +442 -0
- package/templates/skills/knowledge/SKILLS_CATALOG.md +274 -4
- package/templates/skills/knowledge/intelligent-routing/SKILL.md +237 -164
- package/templates/skills/knowledge/parallel-agents/SKILL.md +345 -73
- package/templates/skills/knowledge/plugin-discovery/SKILL.md +582 -0
- package/templates/skills/knowledge/plugin-discovery/scripts/platform_setup.py +1083 -0
- package/templates/skills/knowledge/design-md/README.md +0 -34
- package/templates/skills/knowledge/design-md/SKILL.md +0 -193
- package/templates/skills/knowledge/design-md/examples/DESIGN.md +0 -154
- package/templates/skills/knowledge/notebooklm-mcp/SKILL.md +0 -71
- package/templates/skills/knowledge/notebooklm-mcp/assets/example_asset.txt +0 -24
- package/templates/skills/knowledge/notebooklm-mcp/references/api_reference.md +0 -34
- package/templates/skills/knowledge/notebooklm-mcp/scripts/example.py +0 -19
- package/templates/skills/knowledge/react-components/README.md +0 -36
- package/templates/skills/knowledge/react-components/SKILL.md +0 -53
- package/templates/skills/knowledge/react-components/examples/gold-standard-card.tsx +0 -80
- package/templates/skills/knowledge/react-components/package-lock.json +0 -231
- package/templates/skills/knowledge/react-components/package.json +0 -16
- package/templates/skills/knowledge/react-components/resources/architecture-checklist.md +0 -15
- package/templates/skills/knowledge/react-components/resources/component-template.tsx +0 -37
- package/templates/skills/knowledge/react-components/resources/stitch-api-reference.md +0 -14
- package/templates/skills/knowledge/react-components/resources/style-guide.json +0 -27
- package/templates/skills/knowledge/react-components/scripts/fetch-stitch.sh +0 -30
- package/templates/skills/knowledge/react-components/scripts/validate.js +0 -68
- package/templates/skills/knowledge/self-update/SKILL.md +0 -60
- package/templates/skills/knowledge/self-update/scripts/update_kit.py +0 -103
- package/templates/skills/knowledge/stitch-loop/README.md +0 -54
- package/templates/skills/knowledge/stitch-loop/SKILL.md +0 -235
- package/templates/skills/knowledge/stitch-loop/examples/SITE.md +0 -73
- package/templates/skills/knowledge/stitch-loop/examples/next-prompt.md +0 -25
- package/templates/skills/knowledge/stitch-loop/resources/baton-schema.md +0 -61
- package/templates/skills/knowledge/stitch-loop/resources/site-template.md +0 -104
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Terraform Best Practices for AWS
|
|
2
|
+
|
|
3
|
+
Reference guide for AWS Terraform development.
|
|
4
|
+
|
|
5
|
+
## Provider Selection
|
|
6
|
+
|
|
7
|
+
### AWS Provider vs AWSCC Provider
|
|
8
|
+
|
|
9
|
+
| Provider | Use When |
|
|
10
|
+
| ----------------------------- | ------------------------------------------------------- |
|
|
11
|
+
| **AWS** (`hashicorp/aws`) | Most common resources, extensive documentation |
|
|
12
|
+
| **AWSCC** (`hashicorp/awscc`) | New resources, consistent API behavior, better defaults |
|
|
13
|
+
|
|
14
|
+
**Recommendation:** Prefer AWSCC when available for new projects; it provides better security defaults and consistent API behavior.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## State Management
|
|
19
|
+
|
|
20
|
+
### Remote State with S3
|
|
21
|
+
|
|
22
|
+
```hcl
|
|
23
|
+
terraform {
|
|
24
|
+
backend "s3" {
|
|
25
|
+
bucket = "terraform-state-511383368449"
|
|
26
|
+
key = "project/terraform.tfstate"
|
|
27
|
+
region = "eu-west-1"
|
|
28
|
+
encrypt = true
|
|
29
|
+
dynamodb_table = "terraform-locks"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### State Locking
|
|
35
|
+
|
|
36
|
+
Always enable DynamoDB locking for team environments:
|
|
37
|
+
|
|
38
|
+
```hcl
|
|
39
|
+
resource "aws_dynamodb_table" "terraform_locks" {
|
|
40
|
+
name = "terraform-locks"
|
|
41
|
+
billing_mode = "PAY_PER_REQUEST"
|
|
42
|
+
hash_key = "LockID"
|
|
43
|
+
|
|
44
|
+
attribute {
|
|
45
|
+
name = "LockID"
|
|
46
|
+
type = "S"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
tags = {
|
|
50
|
+
Purpose = "Terraform State Locking"
|
|
51
|
+
ManagedBy = "terraform"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Security Patterns
|
|
59
|
+
|
|
60
|
+
### Least Privilege IAM
|
|
61
|
+
|
|
62
|
+
```hcl
|
|
63
|
+
data "aws_iam_policy_document" "lambda_assume" {
|
|
64
|
+
statement {
|
|
65
|
+
actions = ["sts:AssumeRole"]
|
|
66
|
+
principals {
|
|
67
|
+
type = "Service"
|
|
68
|
+
identifiers = ["lambda.amazonaws.com"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
resource "aws_iam_role" "lambda" {
|
|
74
|
+
name = "lambda-execution-role"
|
|
75
|
+
assume_role_policy = data.aws_iam_policy_document.lambda_assume.json
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Attach only required permissions
|
|
79
|
+
resource "aws_iam_role_policy_attachment" "lambda_basic" {
|
|
80
|
+
role = aws_iam_role.lambda.name
|
|
81
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Encryption at Rest
|
|
86
|
+
|
|
87
|
+
Always enable encryption for data stores:
|
|
88
|
+
|
|
89
|
+
```hcl
|
|
90
|
+
# RDS
|
|
91
|
+
resource "aws_db_instance" "main" {
|
|
92
|
+
# ...
|
|
93
|
+
storage_encrypted = true
|
|
94
|
+
kms_key_id = aws_kms_key.rds.arn
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# EBS
|
|
98
|
+
resource "aws_ebs_volume" "main" {
|
|
99
|
+
# ...
|
|
100
|
+
encrypted = true
|
|
101
|
+
kms_key_id = aws_kms_key.ebs.arn
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# S3
|
|
105
|
+
resource "aws_s3_bucket_server_side_encryption_configuration" "main" {
|
|
106
|
+
bucket = aws_s3_bucket.main.id
|
|
107
|
+
rule {
|
|
108
|
+
apply_server_side_encryption_by_default {
|
|
109
|
+
kms_master_key_id = aws_kms_key.s3.arn
|
|
110
|
+
sse_algorithm = "aws:kms"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Security Groups - Explicit Rules
|
|
117
|
+
|
|
118
|
+
```hcl
|
|
119
|
+
resource "aws_security_group" "web" {
|
|
120
|
+
name = "web-sg"
|
|
121
|
+
description = "Security group for web servers"
|
|
122
|
+
vpc_id = var.vpc_id
|
|
123
|
+
|
|
124
|
+
# HTTPS from anywhere
|
|
125
|
+
ingress {
|
|
126
|
+
from_port = 443
|
|
127
|
+
to_port = 443
|
|
128
|
+
protocol = "tcp"
|
|
129
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
130
|
+
description = "HTTPS traffic"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Explicit egress rules
|
|
134
|
+
egress {
|
|
135
|
+
from_port = 443
|
|
136
|
+
to_port = 443
|
|
137
|
+
protocol = "tcp"
|
|
138
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
139
|
+
description = "HTTPS to external services"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
tags = {
|
|
143
|
+
Name = "web-sg"
|
|
144
|
+
Environment = var.environment
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Tagging Strategy
|
|
152
|
+
|
|
153
|
+
### Default Tags Provider
|
|
154
|
+
|
|
155
|
+
```hcl
|
|
156
|
+
provider "aws" {
|
|
157
|
+
region = "eu-west-1"
|
|
158
|
+
|
|
159
|
+
default_tags {
|
|
160
|
+
tags = {
|
|
161
|
+
Environment = var.environment
|
|
162
|
+
Project = var.project_name
|
|
163
|
+
ManagedBy = "terraform"
|
|
164
|
+
Owner = var.owner
|
|
165
|
+
CostCenter = var.cost_center
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Required Tags
|
|
172
|
+
|
|
173
|
+
| Tag | Purpose |
|
|
174
|
+
| ------------- | --------------------------------- |
|
|
175
|
+
| `Environment` | dev, staging, prod |
|
|
176
|
+
| `Project` | Project/application name |
|
|
177
|
+
| `ManagedBy` | terraform, manual, cloudformation |
|
|
178
|
+
| `Owner` | Team or individual owner |
|
|
179
|
+
| `CostCenter` | For billing allocation |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Modules Best Practices
|
|
184
|
+
|
|
185
|
+
### Module Structure
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
modules/
|
|
189
|
+
└── vpc/
|
|
190
|
+
├── main.tf # Primary resources
|
|
191
|
+
├── variables.tf # Input variables
|
|
192
|
+
├── outputs.tf # Output values
|
|
193
|
+
├── versions.tf # Provider requirements
|
|
194
|
+
└── README.md # Usage documentation
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Module Versioning
|
|
198
|
+
|
|
199
|
+
```hcl
|
|
200
|
+
module "vpc" {
|
|
201
|
+
source = "terraform-aws-modules/vpc/aws"
|
|
202
|
+
version = "~> 5.0" # Allow patch updates
|
|
203
|
+
|
|
204
|
+
# Pin major version to avoid breaking changes
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Local Module Usage
|
|
209
|
+
|
|
210
|
+
```hcl
|
|
211
|
+
module "app_vpc" {
|
|
212
|
+
source = "../../modules/vpc"
|
|
213
|
+
|
|
214
|
+
name = "app-vpc"
|
|
215
|
+
environment = var.environment
|
|
216
|
+
cidr_block = "10.0.0.0/16"
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Variable Best Practices
|
|
223
|
+
|
|
224
|
+
### Type Constraints
|
|
225
|
+
|
|
226
|
+
```hcl
|
|
227
|
+
variable "instance_type" {
|
|
228
|
+
type = string
|
|
229
|
+
default = "t3.micro"
|
|
230
|
+
description = "EC2 instance type"
|
|
231
|
+
|
|
232
|
+
validation {
|
|
233
|
+
condition = can(regex("^t3\\.", var.instance_type))
|
|
234
|
+
error_message = "Instance type must be in the t3 family."
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
variable "allowed_cidrs" {
|
|
239
|
+
type = list(string)
|
|
240
|
+
default = []
|
|
241
|
+
description = "List of CIDRs allowed to access resources"
|
|
242
|
+
|
|
243
|
+
validation {
|
|
244
|
+
condition = alltrue([
|
|
245
|
+
for cidr in var.allowed_cidrs :
|
|
246
|
+
can(cidrhost(cidr, 0))
|
|
247
|
+
])
|
|
248
|
+
error_message = "All values must be valid CIDR blocks."
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Sensitive Variables
|
|
254
|
+
|
|
255
|
+
```hcl
|
|
256
|
+
variable "database_password" {
|
|
257
|
+
type = string
|
|
258
|
+
sensitive = true
|
|
259
|
+
description = "Database master password"
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Lifecycle Rules
|
|
266
|
+
|
|
267
|
+
### Prevent Accidental Destruction
|
|
268
|
+
|
|
269
|
+
```hcl
|
|
270
|
+
resource "aws_db_instance" "main" {
|
|
271
|
+
# ...
|
|
272
|
+
|
|
273
|
+
lifecycle {
|
|
274
|
+
prevent_destroy = true
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Ignore External Changes
|
|
280
|
+
|
|
281
|
+
```hcl
|
|
282
|
+
resource "aws_autoscaling_group" "main" {
|
|
283
|
+
# ...
|
|
284
|
+
|
|
285
|
+
lifecycle {
|
|
286
|
+
ignore_changes = [
|
|
287
|
+
desired_capacity, # Allow autoscaling to manage
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Create Before Destroy
|
|
294
|
+
|
|
295
|
+
```hcl
|
|
296
|
+
resource "aws_instance" "main" {
|
|
297
|
+
# ...
|
|
298
|
+
|
|
299
|
+
lifecycle {
|
|
300
|
+
create_before_destroy = true
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Data Sources
|
|
308
|
+
|
|
309
|
+
### Current Account Info
|
|
310
|
+
|
|
311
|
+
```hcl
|
|
312
|
+
data "aws_caller_identity" "current" {}
|
|
313
|
+
data "aws_region" "current" {}
|
|
314
|
+
|
|
315
|
+
locals {
|
|
316
|
+
account_id = data.aws_caller_identity.current.account_id
|
|
317
|
+
region = data.aws_region.current.name
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Latest AMI
|
|
322
|
+
|
|
323
|
+
```hcl
|
|
324
|
+
data "aws_ami" "amazon_linux" {
|
|
325
|
+
most_recent = true
|
|
326
|
+
owners = ["amazon"]
|
|
327
|
+
|
|
328
|
+
filter {
|
|
329
|
+
name = "name"
|
|
330
|
+
values = ["al2023-ami-*-x86_64"]
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
filter {
|
|
334
|
+
name = "virtualization-type"
|
|
335
|
+
values = ["hvm"]
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Workspace Strategy
|
|
343
|
+
|
|
344
|
+
Use workspaces for environment isolation:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Create workspaces
|
|
348
|
+
terraform workspace new dev
|
|
349
|
+
terraform workspace new staging
|
|
350
|
+
terraform workspace new prod
|
|
351
|
+
|
|
352
|
+
# Select workspace
|
|
353
|
+
terraform workspace select dev
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Reference workspace in code:
|
|
357
|
+
|
|
358
|
+
```hcl
|
|
359
|
+
locals {
|
|
360
|
+
environment = terraform.workspace
|
|
361
|
+
|
|
362
|
+
instance_type = {
|
|
363
|
+
dev = "t3.micro"
|
|
364
|
+
staging = "t3.small"
|
|
365
|
+
prod = "t3.medium"
|
|
366
|
+
}[local.environment]
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Performance Tips
|
|
373
|
+
|
|
374
|
+
### Parallelism
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
# Increase parallelism for large deployments
|
|
378
|
+
terraform apply -parallelism=20
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Target Specific Resources
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# Apply only specific resources
|
|
385
|
+
terraform apply -target=module.vpc
|
|
386
|
+
terraform apply -target=aws_instance.web
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Refresh State
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
# Skip refresh for faster plans
|
|
393
|
+
terraform plan -refresh=false
|
|
394
|
+
```
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# Checkov Security Scanning Reference
|
|
2
|
+
|
|
3
|
+
Comprehensive guide for security and compliance scanning with Checkov.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Scan current directory
|
|
9
|
+
checkov -d .
|
|
10
|
+
|
|
11
|
+
# Scan with specific framework
|
|
12
|
+
checkov -d . --framework terraform
|
|
13
|
+
|
|
14
|
+
# Output as JSON
|
|
15
|
+
checkov -d . -o json > checkov-report.json
|
|
16
|
+
|
|
17
|
+
# Compact output
|
|
18
|
+
checkov -d . --compact
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Common AWS Checks
|
|
24
|
+
|
|
25
|
+
### S3 Buckets
|
|
26
|
+
|
|
27
|
+
| Check ID | Description | Severity |
|
|
28
|
+
| ------------- | --------------------------------- | -------- |
|
|
29
|
+
| `CKV_AWS_18` | S3 bucket access logging enabled | MEDIUM |
|
|
30
|
+
| `CKV_AWS_19` | S3 bucket encryption enabled | HIGH |
|
|
31
|
+
| `CKV_AWS_20` | S3 bucket public access block | HIGH |
|
|
32
|
+
| `CKV_AWS_21` | S3 bucket versioning enabled | MEDIUM |
|
|
33
|
+
| `CKV_AWS_53` | S3 bucket lifecycle configuration | LOW |
|
|
34
|
+
| `CKV_AWS_145` | S3 bucket encrypted with CMK | MEDIUM |
|
|
35
|
+
|
|
36
|
+
### EC2 Instances
|
|
37
|
+
|
|
38
|
+
| Check ID | Description | Severity |
|
|
39
|
+
| ------------- | ------------------------------- | -------- |
|
|
40
|
+
| `CKV_AWS_79` | IMDSv2 required | HIGH |
|
|
41
|
+
| `CKV_AWS_88` | EC2 not assigned public IP | MEDIUM |
|
|
42
|
+
| `CKV_AWS_126` | EC2 detailed monitoring enabled | LOW |
|
|
43
|
+
| `CKV_AWS_135` | EBS optimized instance | LOW |
|
|
44
|
+
| `CKV_AWS_8` | EBS encryption enabled | HIGH |
|
|
45
|
+
|
|
46
|
+
### Security Groups
|
|
47
|
+
|
|
48
|
+
| Check ID | Description | Severity |
|
|
49
|
+
| ------------- | ---------------------------------- | -------- |
|
|
50
|
+
| `CKV_AWS_23` | Security group has description | LOW |
|
|
51
|
+
| `CKV_AWS_24` | No SSH from 0.0.0.0/0 | HIGH |
|
|
52
|
+
| `CKV_AWS_25` | No RDP from 0.0.0.0/0 | HIGH |
|
|
53
|
+
| `CKV_AWS_260` | No unrestricted ingress to port 80 | MEDIUM |
|
|
54
|
+
| `CKV_AWS_277` | No unrestricted egress | LOW |
|
|
55
|
+
|
|
56
|
+
### RDS
|
|
57
|
+
|
|
58
|
+
| Check ID | Description | Severity |
|
|
59
|
+
| ------------- | ----------------------- | -------- |
|
|
60
|
+
| `CKV_AWS_16` | RDS encryption enabled | HIGH |
|
|
61
|
+
| `CKV_AWS_17` | RDS logging enabled | MEDIUM |
|
|
62
|
+
| `CKV_AWS_118` | RDS enhanced monitoring | LOW |
|
|
63
|
+
| `CKV_AWS_157` | RDS multi-AZ enabled | MEDIUM |
|
|
64
|
+
| `CKV_AWS_161` | RDS IAM authentication | MEDIUM |
|
|
65
|
+
|
|
66
|
+
### Lambda
|
|
67
|
+
|
|
68
|
+
| Check ID | Description | Severity |
|
|
69
|
+
| ------------- | ------------------------------- | -------- |
|
|
70
|
+
| `CKV_AWS_45` | Lambda in VPC | MEDIUM |
|
|
71
|
+
| `CKV_AWS_50` | X-Ray tracing enabled | LOW |
|
|
72
|
+
| `CKV_AWS_115` | Reserved concurrency set | LOW |
|
|
73
|
+
| `CKV_AWS_116` | Dead letter queue configured | MEDIUM |
|
|
74
|
+
| `CKV_AWS_173` | Environment variables encrypted | HIGH |
|
|
75
|
+
|
|
76
|
+
### IAM
|
|
77
|
+
|
|
78
|
+
| Check ID | Description | Severity |
|
|
79
|
+
| ------------- | ----------------------------- | -------- |
|
|
80
|
+
| `CKV_AWS_40` | No wildcard actions in IAM | HIGH |
|
|
81
|
+
| `CKV_AWS_49` | No wildcard resources in IAM | HIGH |
|
|
82
|
+
| `CKV_AWS_109` | IAM policy allows assume role | MEDIUM |
|
|
83
|
+
| `CKV_AWS_289` | No admin access policy | CRITICAL |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Skipping Checks
|
|
88
|
+
|
|
89
|
+
### Inline Skip
|
|
90
|
+
|
|
91
|
+
```hcl
|
|
92
|
+
#checkov:skip=CKV_AWS_18:Access logging disabled for non-production
|
|
93
|
+
resource "aws_s3_bucket" "dev" {
|
|
94
|
+
bucket = "my-dev-bucket"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Multiple Skips
|
|
99
|
+
|
|
100
|
+
```hcl
|
|
101
|
+
#checkov:skip=CKV_AWS_18:Access logging disabled for dev
|
|
102
|
+
#checkov:skip=CKV_AWS_21:Versioning not needed for temp data
|
|
103
|
+
resource "aws_s3_bucket" "temp" {
|
|
104
|
+
bucket = "temp-processing-bucket"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Command-Line Skip
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Skip specific checks
|
|
112
|
+
checkov -d . --skip-check CKV_AWS_18,CKV_AWS_21
|
|
113
|
+
|
|
114
|
+
# Skip by severity
|
|
115
|
+
checkov -d . --check LOW --skip-check-severity MEDIUM,HIGH
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Skip File
|
|
119
|
+
|
|
120
|
+
Create `.checkov.yml`:
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
skip-check:
|
|
124
|
+
- CKV_AWS_18 # Access logging for dev buckets
|
|
125
|
+
- CKV_AWS_21 # Versioning for temp buckets
|
|
126
|
+
|
|
127
|
+
framework:
|
|
128
|
+
- terraform
|
|
129
|
+
|
|
130
|
+
compact: true
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## CI/CD Integration
|
|
136
|
+
|
|
137
|
+
### GitHub Actions
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
name: Terraform Security Scan
|
|
141
|
+
|
|
142
|
+
on:
|
|
143
|
+
pull_request:
|
|
144
|
+
paths:
|
|
145
|
+
- "**.tf"
|
|
146
|
+
|
|
147
|
+
jobs:
|
|
148
|
+
checkov:
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
steps:
|
|
151
|
+
- uses: actions/checkout@v4
|
|
152
|
+
|
|
153
|
+
- name: Run Checkov
|
|
154
|
+
uses: bridgecrewio/checkov-action@master
|
|
155
|
+
with:
|
|
156
|
+
directory: .
|
|
157
|
+
framework: terraform
|
|
158
|
+
soft_fail: false
|
|
159
|
+
skip_check: CKV_AWS_18
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Pre-commit Hook
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
# .pre-commit-config.yaml
|
|
166
|
+
repos:
|
|
167
|
+
- repo: https://github.com/bridgecrewio/checkov
|
|
168
|
+
rev: "3.0.0"
|
|
169
|
+
hooks:
|
|
170
|
+
- id: checkov
|
|
171
|
+
args: [--framework, terraform]
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Output Formats
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# CLI output (default)
|
|
180
|
+
checkov -d .
|
|
181
|
+
|
|
182
|
+
# JSON output
|
|
183
|
+
checkov -d . -o json > report.json
|
|
184
|
+
|
|
185
|
+
# JUnit XML (for CI)
|
|
186
|
+
checkov -d . -o junitxml > report.xml
|
|
187
|
+
|
|
188
|
+
# SARIF (for GitHub Security)
|
|
189
|
+
checkov -d . -o sarif > report.sarif
|
|
190
|
+
|
|
191
|
+
# Multiple outputs
|
|
192
|
+
checkov -d . -o cli -o json > report.json
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Fixing Common Issues
|
|
198
|
+
|
|
199
|
+
### CKV_AWS_79: IMDSv2
|
|
200
|
+
|
|
201
|
+
```hcl
|
|
202
|
+
resource "aws_instance" "main" {
|
|
203
|
+
# ... other config
|
|
204
|
+
|
|
205
|
+
metadata_options {
|
|
206
|
+
http_tokens = "required" # Enforce IMDSv2
|
|
207
|
+
http_endpoint = "enabled"
|
|
208
|
+
http_put_response_hop_limit = 1
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### CKV_AWS_20: S3 Public Access Block
|
|
214
|
+
|
|
215
|
+
```hcl
|
|
216
|
+
resource "aws_s3_bucket_public_access_block" "main" {
|
|
217
|
+
bucket = aws_s3_bucket.main.id
|
|
218
|
+
|
|
219
|
+
block_public_acls = true
|
|
220
|
+
block_public_policy = true
|
|
221
|
+
ignore_public_acls = true
|
|
222
|
+
restrict_public_buckets = true
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### CKV_AWS_24: No SSH from 0.0.0.0/0
|
|
227
|
+
|
|
228
|
+
```hcl
|
|
229
|
+
resource "aws_security_group_rule" "ssh" {
|
|
230
|
+
type = "ingress"
|
|
231
|
+
from_port = 22
|
|
232
|
+
to_port = 22
|
|
233
|
+
protocol = "tcp"
|
|
234
|
+
# Use specific CIDR, not 0.0.0.0/0
|
|
235
|
+
cidr_blocks = ["10.0.0.0/8"]
|
|
236
|
+
security_group_id = aws_security_group.main.id
|
|
237
|
+
description = "SSH from internal network"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### CKV_AWS_16: RDS Encryption
|
|
242
|
+
|
|
243
|
+
```hcl
|
|
244
|
+
resource "aws_db_instance" "main" {
|
|
245
|
+
# ... other config
|
|
246
|
+
|
|
247
|
+
storage_encrypted = true
|
|
248
|
+
kms_key_id = aws_kms_key.rds.arn
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### CKV_AWS_173: Lambda Environment Encryption
|
|
253
|
+
|
|
254
|
+
```hcl
|
|
255
|
+
resource "aws_lambda_function" "main" {
|
|
256
|
+
# ... other config
|
|
257
|
+
|
|
258
|
+
kms_key_arn = aws_kms_key.lambda.arn
|
|
259
|
+
|
|
260
|
+
environment {
|
|
261
|
+
variables = {
|
|
262
|
+
API_KEY = var.api_key # Will be encrypted with KMS
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Custom Policies
|
|
271
|
+
|
|
272
|
+
### Python Custom Check
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
# custom_checks/s3_naming.py
|
|
276
|
+
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
|
|
277
|
+
from checkov.common.models.enums import CheckResult, CheckCategories
|
|
278
|
+
|
|
279
|
+
class S3NamingConvention(BaseResourceCheck):
|
|
280
|
+
def __init__(self):
|
|
281
|
+
name = "S3 bucket follows naming convention"
|
|
282
|
+
id = "CKV_CUSTOM_1"
|
|
283
|
+
supported_resources = ["aws_s3_bucket"]
|
|
284
|
+
categories = [CheckCategories.CONVENTION]
|
|
285
|
+
super().__init__(name=name, id=id, categories=categories,
|
|
286
|
+
supported_resources=supported_resources)
|
|
287
|
+
|
|
288
|
+
def scan_resource_conf(self, conf):
|
|
289
|
+
bucket_name = conf.get("bucket", [""])[0]
|
|
290
|
+
if bucket_name.startswith("company-"):
|
|
291
|
+
return CheckResult.PASSED
|
|
292
|
+
return CheckResult.FAILED
|
|
293
|
+
|
|
294
|
+
check = S3NamingConvention()
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Run with custom checks:
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
checkov -d . --external-checks-dir ./custom_checks
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Severity Levels
|
|
306
|
+
|
|
307
|
+
| Level | Description | Action |
|
|
308
|
+
| ------------ | ------------------------ | ------------------- |
|
|
309
|
+
| **CRITICAL** | Must fix immediately | Block deployment |
|
|
310
|
+
| **HIGH** | Security vulnerability | Fix before prod |
|
|
311
|
+
| **MEDIUM** | Security best practice | Fix soon |
|
|
312
|
+
| **LOW** | Hardening recommendation | Fix when convenient |
|
|
313
|
+
|
|
314
|
+
### Filter by Severity
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# Only high and critical
|
|
318
|
+
checkov -d . --check HIGH,CRITICAL
|
|
319
|
+
|
|
320
|
+
# Fail on critical only
|
|
321
|
+
checkov -d . --hard-fail-on CRITICAL
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Performance Tips
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Parallel scanning
|
|
330
|
+
checkov -d . --parallelism 8
|
|
331
|
+
|
|
332
|
+
# Skip downloads
|
|
333
|
+
checkov -d . --skip-download
|
|
334
|
+
|
|
335
|
+
# Cache results
|
|
336
|
+
checkov -d . --cache-dir /tmp/.checkov_cache
|
|
337
|
+
```
|