Instruction file imported from zscaler/pulumi-zia (
.cursor/rules/add-resource.mdc). Copyright stays with the author.
Adding a New Resource
Source of Truth
All resources are backed by github.com/zscaler/zscaler-sdk-go/v3, vendored at
vendor/github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia/services/<package>/.
New resources/attributes must exist in the SDK first. Always start by reading
the SDK struct and CRUD functions to determine fields, types, and method signatures.
If the SDK needs updating: go get github.com/zscaler/zscaler-sdk-go/v3@latest && go mod vendor
Steps
- Check the SDK: Read the struct and CRUD functions in
vendor/github.com/zscaler/zscaler-sdk-go/v3/zscaler/zia/services/<package>/ - Create
provider/<resource_name>.gowith Args, State, Resource structs mapping to SDK fields - Implement CRUD:
Create,Read,Update,Deletecalling SDK functions - Add Annotate() methods:
- Resource: value receiver,
describeResource()with Hugo shortcode examples - Args: pointer receiver, describe every input property
- State: pointer receiver, describe output-only properties
- Resource: value receiver,
- Register in
provider/provider.gounderWithResources() - Build:
make provider && make generate_schema - Verify: Check
schema.jsoncontains the new resource with descriptions
Template
type NewResourceArgs struct {
Name string `pulumi:"name"`
Description *string `pulumi:"description,optional"`
}
type NewResourceState struct {
NewResourceArgs
ResourceId string `pulumi:"resourceId"`
}
type NewResource struct{}
func (NewResource) Annotate(a infer.Annotator) {
describeResource(a, &NewResource{}, "Description with examples...")
}
func (a *NewResourceArgs) Annotate(ann infer.Annotator) {
ann.Describe(&a.Name, "The name of the resource.")
}
func (s *NewResourceState) Annotate(a infer.Annotator) {
a.Describe(&s.ResourceId, "The ID of the resource.")
}
License Header
Use MIT header (see existing files for exact text).