3 ms·
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?
by OliverGilan 4y ago
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?
- eurasiantiger 4y agoJust 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.
- campers 4y agoCalling 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/monitoring/alertpolicy/#monitoring-alert-policy-basic 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)