Skip to main content

abstractAResource <S, T>

The base class of every resource - the nodes that describe actual cloud infrastructure.

Where a model says what you want, a resource says what exists. Resources are never constructed by you directly; a model action declares them, and Octo diffs the declared graph against the last committed one to decide what to create, update, or destroy.

A resource is identified by its resourceId, configured by its properties, and reports back through its response once the infrastructure exists. The ID it is created with is its localResourceId, which only has to be unique within its scope: where the node creating the resource sits in the model graph. Octo makes the resourceId from the two.

Most resources extend ATerraformResource rather than this class.

@group

Resources

@see

Definition of Resources.

Hierarchy

Implements

  • IResource<S, T>

Index

Properties

readonlylocalResourceId

localResourceId: S[localResourceId]

The ID of the resource, unique within its scope.

readonlyparents

parents: (UnknownResource | MatchingResource<BaseResourceSchema>)[] = []

The resources this one is built on top of. A parent is always created before its children, and destroyed after them.

readonlyproperties

properties: S[properties]

The desired configuration of the resource.

readonlyresponse

response: S[response] = {}

What the cloud provider reported back about this resource, e.g. an ARN or a generated ID. It is empty until the resource has actually been created, and is what other resources read when they need to reference this one.

readonlyscope

scope: string[] = ...

The contexts of the models this resource is placed under, sorted. Octo derives it from the node whose action created the resource; a resource created outside a model action has an empty scope.

readonlytags

tags: S[tags] = {}

The tags applied to this resource. See Octo.registerTags to set them in bulk.

staticreadonlyinheritedNODE_NAME

NODE_NAME: string

The name of the node. All nodes with same name are of the same category.

staticreadonlyinheritedNODE_PACKAGE

NODE_PACKAGE: string

The package of the node.

staticreadonlyinheritedNODE_SCHEMA

NODE_SCHEMA: unknown

The schema of the node.

staticreadonlyinheritedNODE_TYPE

NODE_TYPE: NodeType

The type of the node.

Accessors

resourceId

  • get resourceId(): S[resourceId]
  • The ID of the resource, unique across the infrastructure: its localResourceId, followed by a hash of its scope when it has one.


    Returns S[resourceId]

Methods

addFieldDependency

  • addFieldDependency(): void
  • @deprecated

    Field dependencies are not supported in resources!


    Returns void

addRelationship

  • @deprecated

    Relationships are not supported in resources!


    Returns { thatToThisDependency: Dependency; thisToThatDependency: Dependency }

diffUnpack

  • diffUnpack(diff: Diff): Diff<UnknownNode, unknown>[]
  • Splits one diff into the diffs a resource action will actually receive.

    Override it when a single change on this resource has to be applied as several ordered steps. The default returns the diff unchanged.


    Parameters

    Returns Diff<UnknownNode, unknown>[]

findParentsByProperty

  • findParentsByProperty(filters: { key: string; value: unknown }[]): UnknownResource[]
  • To find this resource's parents whose properties match every given filter.


    Parameters

    • filters: { key: string; value: unknown }[]

      Each filter is a property key the parent must carry with the given value.

    Returns UnknownResource[]

findParentsByTag

  • findParentsByTag(filters: { key: string; value: string }[]): UnknownResource[]
  • To find this resource's parents whose tags match every given filter.


    Parameters

    • filters: { key: string; value: string }[]

      Each filter is a tag key the parent must carry with the given value.

    Returns UnknownResource[]

getBoundaryMembers

  • getBoundaryMembers(): UnknownResource[]
  • @deprecated

    Boundary is not supported in resources!


    Returns UnknownResource[]

getExternalTriggerProperties

  • getExternalTriggerProperties(): Partial<S[properties]>
  • The properties whose change means an external resource has to be run again. Terraform hashes them into the trigger of the null_resource that stands in for the resource, which is how it decides to call back.

    A resource that overrides diffProperties to ignore a property must exclude that property here too. The two answer the same question, and terraform plans a replacement for any property only this one covers, which octo then reports no change for.


    Returns Partial<S[properties]>

getSiblings

  • getSiblings(): {}
  • @deprecated

    Siblings are not supported in resources!


    Returns {}

isMarkedDeleted

  • isMarkedDeleted(): boolean
  • Whether this resource is marked for deletion, and will leave the graph at the end of the transaction.


    Returns boolean

remove

  • remove(force?: boolean): void
  • To mark this resource for deletion. It leaves the graph at the end of the transaction.

    @throws

    RemoveResourceError If the resource still has children, and force is not set.


    Parameters

    • force: boolean = false

      Removes the resource even if other resources still depend on it.

    Returns void

setResponse

  • setResponse(response: S[response]): void
  • To record what the cloud provider reported back about this resource. Keys absent from response are left as they were.


    Parameters

    • response: S[response]

    Returns void