validate
Validate the configuration file without communicating with cloud providers. This checks syntax, type correctness, resource schema compliance, and module resolution.
Usage
carina validate [PATH]PATH defaults to . (current directory). It can be a .crn file or a directory containing .crn files.
What It Checks
- Syntax — Parses all
.crnfiles using the Carina grammar. Reports line and column for parse errors. - Resource types — Validates that resource types exist in the provider schema (e.g.,
aws.s3.bucket). - Attribute types — Checks that attribute values match the expected types defined in the resource schema.
- Module resolution — Resolves
importstatements and validates module arguments. - Unused bindings — Warns about
letbindings that are never referenced. These can be replaced with anonymous resources. - Duplicate attributes — Warns when the same attribute key appears multiple times in a resource block. The last value wins, but this is likely unintentional.
Output
On success, Carina prints the number of validated resources and lists each resource ID:
Validating...✓ 3 resources validated successfully. • aws.s3.bucket.my-bucket • aws.ec2.vpc.main • aws.ec2.subnet.publicWarnings are printed after the success message:
⚠ Unused let binding 'temp'. Consider using an anonymous resource instead.⚠ main.crn:Duplicate attribute 'tags' at line 12 (first defined on line 8). The last value will be used.On failure, Carina prints the error and exits with code 1.
Flags
--json
Output results as structured JSON instead of human-readable text.
carina validate --json{ "status": "ok", "resource_count": 3, "resources": [ "aws.s3.bucket.my-bucket", "aws.ec2.vpc.main", "aws.ec2.subnet.public" ]}When warnings are present, they are included in the output:
{ "status": "ok", "resource_count": 2, "resources": ["aws.s3.bucket.my-bucket", "aws.ec2.vpc.main"], "warnings": [ {"type": "unused_binding", "message": "Unused let binding 'temp'"}, {"type": "duplicate_attribute", "message": "Duplicate attribute 'tags' at line 12", "file": "main.crn"} ]}Examples
Validate the current directory:
carina validateValidate a specific file:
carina validate infra.crn