Skip to content

Plugin Development

Plugins extend StackSolo with new resource types and providers.

my-plugin/
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── src/
├── index.ts # Plugin entry point
└── resources/
└── my-resource.ts
src/index.ts
import { StackSoloPlugin } from '@stacksolo/core';
import { myResource } from './resources/my-resource';
const plugin: StackSoloPlugin = {
name: 'my-plugin',
version: '0.1.0',
resources: [myResource],
};
export default plugin;
src/resources/my-resource.ts
import { defineResource } from '@stacksolo/core';
export const myResource = defineResource({
id: 'my-plugin:my-resource',
name: 'My Resource',
configSchema: {
type: 'object',
properties: {
name: { type: 'string' },
// ... JSON Schema
},
required: ['name'],
},
generate(config, context) {
return {
imports: ['import { Something } from "cdktf"'],
code: `new Something(stack, '${config.name}', { ... })`,
outputs: ['url'],
};
},
});
tsup.config.ts
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['esm'],
target: 'node18',
external: ['@stacksolo/core'],
dts: true,
});
{
"name": "@my-org/stacksolo-plugin-example",
"type": "module",
"main": "dist/index.js",
"peerDependencies": {
"@stacksolo/core": "^0.1.0"
}
}
{
"project": {
"plugins": ["@my-org/stacksolo-plugin-example"],
"networks": [{
"myResources": [{ "name": "example" }]
}]
}
}