Components (SDK)
Create reusable Microtica infrastructure components and read their config schemas with the SDK's components namespace.
The components namespace manages components — the reusable infrastructure building blocks you instantiate as resources inside environments.
A component is a reference over a pipeline plus the build step (artifactStep) that produces its infrastructure artifact. Its deployable versions are that pipeline's successful builds, so a component becomes usable once its pipeline has a successful build of the artifact step. Creating a component stores the reference only — it doesn't build anything.
Methods
| Method | Returns |
|---|---|
components.list(projectId) | Components in the project. |
components.get(projectId, componentId, version?) | One component; version pins a build. |
components.getSchema(projectId, componentId, version?) | The config schema for a version. |
components.create(projectId, request) | The new component's id. |
components.delete(projectId, componentId) | Delete a component. |
Create a component
create references an existing pipeline and the step that builds the component's artifact.
const { componentId } = await microtica.components.create(projectId, {
name: "my-vpc",
description: "Networking VPC",
pipelineId,
artifactStep: "BuildArtifact",
type: "vpc",
infrastructureAsCodeTool: "terraform",
cloudProvider: "aws",
});type is one of kubernetes, database, storage, virtual-machine, lambda, vpc, or other.
Config schemas
getSchema returns the config JSON schema for a component at a given version (default "latest", resolved server-side to the latest successful build). The schema is specific to both the component and the version, and it's what drives the configuration you supply to envs.addResource.
const { componentVersion, schema } = await microtica.components.getSchema(
projectId,
componentId,
);It throws if the component has no successful build yet — without a version there's no schema. Build the component's pipeline first, then read the schema.