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
The resource's name, unique in its package.
schema: Constructable<ResourceSchema<T>>
The schema of the resource.
options: { destroyLosesData?: string[]; 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.
destroyLosesDatanames the Terraform types of the blocks holding data that is lost when one is destroyed, such asaws_s3_bucketbut not its policy. Validate, and apply's check for destroys, add a message to each destroy of such a block, whatever the cause. Set it on a resource holding data octo cannot put back, such as rows, objects or images; not on content octo rewrites every apply, nor on a loss that breaks loudly. A named type the resource renders no block of is refused at generate; a block holding data added to the resource later is marked only once its type is named here.uniquePropertieslists the names the cloud requires unique, one entry per name: every one the provider's documentation says it keeps unique.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, as the provider's documentation states it. A resource missing one is refused. An emptywithinmakes the name unique across the app.
Generate refuses two values of
paththat share the values ofwithin, whether they come from two resources of the class or from one. Only resources of one class are compared with each other, and a class declaring no names is not checked.optionaldestroyLosesData: string[] = []
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: Constructable<T>) => void
The decorated class.
Parameters
constructor: Constructable<T>
Returns void
A
@Resourceis a class decorator and must be placed on top of a class representing a resource.A resource holding names the cloud requires unique:
A resource holding data a destroy loses:
Decorators
Definition of Resources.