Resource
Callable
Type parameters
- T: UnknownResource
Parameters
packageName: string
The name of the package under which the resource is registered. Selecting a unique package name helps avoid collisions between same resource class names across different libraries. You will reuse the same package name throughout your library for different Octo components you create.
resourceName: string
a string that uniquely represents the name of the resource.
schema: Constructable<ResourceSchema<T>>
The schema of the resource.
options: { destroyLosesData?: boolean; uniqueProperties?: { path: { [ K in string ]-?: unknown extends ResourceSchema<T>[properties][K] ? K | `${K}.${string}` | `${K}[]` | `${K}[].${string}` : NonNullable<...[...][K]> extends readonly E[] ? (NonNullable<...> extends string ? `${...}[]` : never) | (NonNullable<...> extends object ? `${...}[].${...}` : never) : NonNullable<...[...]> extends string ? K : NonNullable<...> extends object ? `${...}.${...}` : never }[keyof ResourceSchema<T>[properties] & string]; within: (keyof ResourceSchema<T>[properties] & string)[] }[] } = {}
Optional settings of the resource.
destroyLosesDatamarks the resource as holding data that is lost when it is destroyed. Validate, and apply's check for destroys, add a message to each destroy of it, whatever the cause.uniquePropertieslists the names the cloud requires unique, one entry per name.pathis a dot path through the resource's properties, with[]after a key holding an array. A resource with no value atpathis not checked.withinnames the properties whose values form the name's domain. A resource missing one is refused. An emptywithinmakes the name unique across the app.
Only resources of one class are compared with each other, and a class declaring no names is not checked.
optionaldestroyLosesData: boolean = false
optionaluniqueProperties: { path: { [ K in string ]-?: unknown extends ResourceSchema<T>[properties][K] ? K | `${K}.${string}` | `${K}[]` | `${K}[].${string}` : NonNullable<...[...][K]> extends readonly E[] ? (NonNullable<...> extends string ? `${...}[]` : never) | (NonNullable<...> extends object ? `${...}[].${...}` : never) : NonNullable<...[...]> extends string ? K : NonNullable<...> extends object ? `${...}.${...}` : never }[keyof ResourceSchema<T>[properties] & string]; within: (keyof ResourceSchema<T>[properties] & string)[] }[] = []
Returns (constructor: any) => void
The decorated class.
Parameters
constructor: any
Returns void
A
@Resourceis a class decorator and must be placed on top of a class representing a resource.A resource whose properties hold a name the cloud requires unique declares it in
options.uniqueProperties, and generate refuses two values ofpaththat share the values ofwithin, whether they come from two resources of the class or from one.A resource holding data octo cannot put back from its inputs - a table's rows, a filesystem's files - sets
options.destroyLosesData, and every destroy terraform plans of it is reported as losing data.Decorators
Definition of Resources.