Skip to content

validate

Validate the configuration file without communicating with cloud providers. This checks syntax, type correctness, resource schema compliance, and module resolution.

Usage

Terminal window
carina validate [PATH]

PATH defaults to . (current directory). It can be a .crn file or a directory containing .crn files.

What It Checks

  1. Syntax — Parses all .crn files using the Carina grammar. Reports line and column for parse errors.
  2. Resource types — Validates that resource types exist in the provider schema (e.g., aws.s3.bucket).
  3. Attribute types — Checks that attribute values match the expected types defined in the resource schema.
  4. Module resolution — Resolves import statements and validates module arguments.
  5. Unused bindings — Warns about let bindings that are never referenced. These can be replaced with anonymous resources.
  6. 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.public

Warnings 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.

Terminal window
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:

Terminal window
carina validate

Validate a specific file:

Terminal window
carina validate infra.crn