template-validator
Validates CloudFormation templates for syntax, security, and best practices. Use when validating CloudFormation templates, checking for security issues, or ensuring compliance with best practices.
What this skill does
# Template Validator
## Quick Start
Validate CloudFormation templates for syntax errors, security issues, and adherence to best practices before deployment.
## Instructions
### Step 1: Validate template syntax
```bash
# Basic validation
aws cloudformation validate-template \
--template-body file://template.yaml
# Validation with parameters
aws cloudformation validate-template \
--template-body file://template.yaml \
--parameters ParameterKey=Param1,ParameterValue=Value1
```
**Check for:**
- Valid YAML/JSON syntax
- Required template sections
- Valid resource types
- Correct intrinsic function usage
- Parameter references
### Step 2: Use cfn-lint for comprehensive checks
```bash
# Install cfn-lint
pip install cfn-lint
# Validate template
cfn-lint template.yaml
# Validate with specific rules
cfn-lint template.yaml --ignore-checks W
# Output as JSON
cfn-lint template.yaml --format json
```
**cfn-lint checks:**
- Template structure
- Resource properties
- Best practices
- Security issues
- Regional availability
### Step 3: Security validation
**Check IAM policies:**
```yaml
# Review for overly permissive policies
Resources:
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ec2.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: AppPolicy
PolicyDocument:
Statement:
# Avoid wildcards
- Effect: Allow
Action: s3:* # Too permissive!
Resource: '*' # Too broad!
```
**Better approach:**
```yaml
Policies:
- PolicyName: AppPolicy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:PutObject
Resource: !Sub '${MyBucket.Arn}/*'
```
**Check security groups:**
```yaml
# Avoid open access
Resources:
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
SecurityGroupIngress:
# Don't allow 0.0.0.0/0 for SSH
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0 # Security risk!
```
**Better approach:**
```yaml
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 10.0.0.0/8 # Restrict to internal network
```
### Step 4: Check resource dependencies
**Verify DependsOn usage:**
```yaml
Resources:
# Explicit dependency needed
Instance:
Type: AWS::EC2::Instance
DependsOn: InternetGatewayAttachment
Properties:
# ...
# Implicit dependency via Ref
SecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref SecurityGroup # Implicit dependency
```
**Check for circular dependencies:**
- Review all DependsOn relationships
- Check Ref and GetAtt usage
- Verify no circular references
### Step 5: Validate best practices
**Use specific resource names:**
```yaml
# Good
Resources:
WebServerSecurityGroup:
Type: AWS::EC2::SecurityGroup
# Avoid generic names
Resources:
SecurityGroup1:
Type: AWS::EC2::SecurityGroup
```
**Add descriptions:**
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Web application infrastructure with ALB and Auto Scaling
Parameters:
InstanceType:
Type: String
Description: EC2 instance type for web servers
```
**Use tags:**
```yaml
Resources:
Instance:
Type: AWS::EC2::Instance
Properties:
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-WebServer'
- Key: Environment
Value: !Ref Environment
- Key: ManagedBy
Value: CloudFormation
```
## Common Validation Checks
### Syntax Validation
**Valid YAML structure:**
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Template description
Parameters:
# Parameters section
Resources:
# Resources section (required)
Outputs:
# Outputs section
```
**Intrinsic functions:**
```yaml
# Correct
Value: !Ref MyResource
Value: !GetAtt MyResource.Attribute
Value: !Sub '${MyResource}'
# Incorrect
Value: Ref: MyResource # Wrong syntax
Value: !GetAtt MyResource # Missing attribute
```
### Security Validation
**IAM policies:**
- No wildcards in actions unless necessary
- Specific resources instead of '*'
- Least privilege principle
- No hardcoded credentials
**Security groups:**
- No 0.0.0.0/0 for sensitive ports (22, 3389, 3306, 5432)
- Specific port ranges
- Documented ingress rules
**Encryption:**
- Enable encryption for S3 buckets
- Enable encryption for EBS volumes
- Enable encryption for RDS instances
- Use KMS keys for sensitive data
### Resource Validation
**Required properties:**
```yaml
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
# BucketName is optional but recommended
BucketName: !Sub '${AWS::StackName}-bucket'
```
**Valid property values:**
```yaml
Resources:
Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t3.micro # Must be valid instance type
ImageId: ami-12345678 # Must be valid AMI ID
```
## Validation Tools
### AWS CLI
```bash
# Validate template
aws cloudformation validate-template \
--template-body file://template.yaml
# Create change set (validates before applying)
aws cloudformation create-change-set \
--stack-name my-stack \
--change-set-name my-changes \
--template-body file://template.yaml
# Describe change set
aws cloudformation describe-change-set \
--stack-name my-stack \
--change-set-name my-changes
```
### cfn-lint
```bash
# Basic validation
cfn-lint template.yaml
# Ignore warnings
cfn-lint template.yaml --ignore-checks W
# Specific regions
cfn-lint template.yaml --regions us-east-1 us-west-2
# Custom rules
cfn-lint template.yaml --append-rules custom-rules/
```
### cfn-nag
```bash
# Install cfn-nag
gem install cfn-nag
# Scan template
cfn_nag_scan --input-path template.yaml
# Scan with rules
cfn_nag_scan --input-path template.yaml --deny-list-path rules.txt
```
### TaskCat
```bash
# Install taskcat
pip install taskcat
# Test template
taskcat test run
# Configuration in .taskcat.yml
project:
name: my-project
regions:
- us-east-1
- us-west-2
tests:
default:
template: template.yaml
parameters:
InstanceType: t3.micro
```
## Validation Checklist
**Template structure:**
- [ ] Valid YAML/JSON syntax
- [ ] AWSTemplateFormatVersion present
- [ ] Description provided
- [ ] Resources section present
**Parameters:**
- [ ] Descriptive names
- [ ] Descriptions provided
- [ ] Validation constraints (AllowedValues, AllowedPattern)
- [ ] Appropriate defaults
- [ ] NoEcho for sensitive values
**Resources:**
- [ ] Descriptive logical IDs
- [ ] Required properties present
- [ ] Valid property values
- [ ] Appropriate DependsOn usage
- [ ] Tags applied
**Security:**
- [ ] IAM policies follow least privilege
- [ ] No hardcoded credentials
- [ ] Security groups restrict access
- [ ] Encryption enabled where appropriate
- [ ] No overly permissive policies
**Outputs:**
- [ ] Descriptive names
- [ ] Descriptions provided
- [ ] Appropriate exports
- [ ] Conditional outputs where needed
**Best practices:**
- [ ] Consistent naming convention
- [ ] Appropriate use of parameters
- [ ] Cross-stack references via exports
- [ ] Proper error handling
- [ ] Documentation in descriptions
## Advanced
For detailed information, see:
- [Security Best Practices](reference/security-best-practices.md) - Comprehensive security validation guide
- [Validation Rules](reference/validation-rules.md) - Complete list of validation rules and checks
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.