Skip to main content
Documentation

Resources

Resources are the core building blocks in Kite. They represent cloud infrastructure components that will be provisioned.

Basic Syntax

resource TypeName resourceName {
    property        = value
    anotherProperty = "string value"
}

Simple Resource

resource S3.Bucket photos {
    name   = "my-photos-bucket"
    region = "us-east-1"
}

Resource with Schema Type

schema ServerConfig {
    string instanceType = "t3.micro"
    number port         = 8080
    boolean public      = false
}

resource ServerConfig webServer {
    instanceType        = "t3.large"
    port                = 443
    public              = true
}

Dynamic Resource Names

Resource names can be dynamic using expressions:

var env  = "production"

resource S3.Bucket storage {
    name = "data-${env}"  // "data-production"
}

Resource Properties

resource EC2.Instance server {
    name           = "web-server"           // String property
    port           = 8080                   // Number property
    public         = true                   // Boolean property
    securityGroups = ["sg-001", "sg-002"]   // Array property
    // Object property
    tags           = {
        Environment: "production",
        Team: "platform"
    }
}

Multiple Resources

Using @count Decorator

@count(3)
resource EC2.Instance server {
    name = "server-${count}"  // "server-0", "server-1", "server-2"
}

Using For Loops

var environments = ["dev", "staging", "prod"]

[for env in environments]
resource S3.Bucket bucket {
    name         = "data-${env}"
}

Resource References

Resources can reference other resources:

resource VPC.Network mainVpc {
    cidr     = "10.0.0.0/16"
}

resource VPC.Subnet publicSubnet {
    vpcId    = mainVpc.id
    cidr     = "10.0.1.0/24"
}

resource EC2.Instance server {
    subnetId = publicSubnet.id
    vpcId    = mainVpc.id
}

Resource Decorators

@provider

@provider("aws")
resource S3.Bucket photos {
    name = "photos"
}

@existing

Reference existing cloud resources:

@existing("arn:aws:s3:::existing-bucket")
resource S3.Bucket imported {}

@dependsOn

resource VPC.Subnet subnet { ... }

@dependsOn(subnet)
resource EC2.Instance server {
    subnetId = subnet.id
}

@tags

@tags({ Environment: "prod", Team: "platform" })
resource S3.Bucket photos {
    name = "photos"
}

Cloud-Generated Properties

Some properties are set by the cloud provider after resource creation:

schema AwsInstance {
    string name                  // User-set
    @cloud string arn            // Cloud-generated
    @cloud(importable) string id // Cloud-generated, can be used for import
}

resource AwsInstance server {
    name                = "web-server"
    // arn and id are NOT set here - they come from AWS after apply
}

// Access cloud-generated properties in outputs
output string serverArn = server.arn

Terraform-Backed Resources

You can use any of Terraform's 3,000+ providers as resource types via the tf/ import prefix:

import Instance from "tf/aws"

resource Instance web {
    ami          = "ami-0123456789"
    instanceType = "t3.micro"
    tags         = { Name: "web-server" }
}

See Terraform Bridge for naming conventions, data sources, version constraints, and more.

Next: Learn about Components - reusable infrastructure modules.