Types & Values
The Carina DSL is a statically-aware language with the following value types.
Primitive Types
String
Strings are enclosed in double quotes:
let name = 'my-vpc'let region = 'ap-northeast-1'Escape Sequences
Strings support the following escape sequences:
| Sequence | Meaning |
|---|---|
\" | Double quote |
\\ | Backslash |
\n | Newline |
\r | Carriage return |
\t | Tab |
\$ | Literal dollar sign (prevents interpolation) |
String Interpolation
Embed expressions inside strings with ${}:
let env = 'prod'let name = "vpc-${env}" # => 'vpc-prod'let cidr = "${base_cidr}" # => value of base_cidrlet tag = "${env}-${service}" # => 'prod-web'Any expression can appear inside ${}, including function calls:
let tag = "vpc-${join("-", ["prod", "web"])}"Int
Integer values, optionally negative:
let port = 443let offset = -1let count = 0Float
Floating-point values with a decimal point:
let ratio = 0.5let threshold = -3.14Bool
Boolean values true or false:
let enabled = truelet public = falseCollection Types
List
Ordered sequences enclosed in square brackets:
let zones = ['ap-northeast-1a', 'ap-northeast-1c', 'ap-northeast-1d']let ports = [80, 443, 8080]let empty = []Lists can contain mixed types and a trailing comma is allowed:
let mixed = [ 'hello', 42, true,]Map
Key-value collections enclosed in curly braces. Keys are identifiers (unquoted), values are expressions:
let config = { dev = '10.0.0.0/16' stg = '10.1.0.0/16'}Maps are also used for resource tags and nested configuration:
awscc.ec2.vpc { cidr_block = '10.0.0.0/16'
tags = { Name = 'main' Environment = 'prod' }}Namespaced Identifiers
Dot-separated identifiers are used for resource types and enum values. They are not strings and are not quoted.
Resource Types
Resource types use the format provider.service.resource_type:
awscc.ec2.vpc { ... }awscc.ec2.subnet { ... }awscc.s3.bucket { ... }Enum Identifiers
Enum values are namespaced identifiers that represent predefined constants:
# Provider-level enumsawscc.Region.ap_northeast_1aws.Region.us_east_1
# Resource-level enumsawscc.ec2.vpc.InstanceTenancy.defaultEnum identifiers are used directly as attribute values without quotes:
provider awscc { region = awscc.Region.ap_northeast_1}
awscc.ec2.vpc { instance_tenancy = awscc.ec2.vpc.InstanceTenancy.default}Resource References
When a resource is bound with let, its attributes can be accessed using dot notation:
let vpc = awscc.ec2.vpc { cidr_block = '10.0.0.0/16'}
let subnet = awscc.ec2.subnet { vpc_id = vpc.vpc_id # Reference vpc's vpc_id attribute cidr_block = '10.0.1.0/24'}Chained Access
Dot notation can be chained for nested access:
let sg = network.security_group.group_idIndex Access
Use square brackets to access list elements or map values:
let first_zone = zones[0]let dev_cidr = config['dev']Index and field access can be combined:
let subnet_id = subnets[0].subnet_idType Expressions
Type expressions are used in arguments and attributes blocks in modules, and in function parameters.
Simple Types
arguments { name : string count : int ratio : float enabled : bool cidr_block: cidr role_arn : arn}Generic Types
list and map accept a type parameter:
arguments { subnet_ids : list(string) cidr_blocks : list(cidr) tags : map(string)}Resource Type References
Resource types can be used as type expressions to indicate a reference:
attributes { vpc_id : awscc.ec2.vpc = vpc.vpc_id subnet_id: awscc.ec2.subnet = subnet.subnet_id}Null
The null literal represents the absence of a value. It can only appear in validate expressions such as require statements and argument validation:
require value != null, 'Value must not be null'