Hacker News new | past | comments | ask | show | jobs | submit login

+1 for TypeScript for config. I've been using Pulumi with TS to create a simple DSL to define all our GitLab config and alerting policies in GCP. It makes it easy to have concise definitions and quickly refactor the DSL with confidence.

Having a proper type system removes so many possibilities of inevitable accidental configuration mistakes. One of our other types of deployment projects has a yaml configuration. One time a section had the wrong tab indenting, took a little while to debug through why a table wasn't being provisioned.




I’d love to learn more about how you do this. Do you have any helpful resources that I can look at to understand the process of creating a DSL with TS + Pulumi?


Calling it a DSL is maybe bit of a stretch, its just creating a concise abstraction above the provided API.

So instead of having 20 lines of code for every alert policy like at https://www.pulumi.com/registry/packages/gcp/api-docs/monito... you create a function that generates all the standardised alerts from concise strongly typed config such as

    cloudSqlAlerts({
        instanceId: 'sql-main',
        highCpu: {
            percent: 70,
            duration: _5min
        },
        highMemory: {
            percent: 80,
            duration: _5min
        },
        highDisk: {
            percent: 80,
            duration: _10min
        },
        deadlockDetection: true
    }, 
    projectNotificationChannels)


Just create types for all objects in your configuration as well as the configuration object itself.

The ”DSL” is the typings, and the rest is nothing more than a simple TS program which calls JSON.stringify() with the type-checked config object and writes the resulting string to disk.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: