@cdk-x/hetzner
    Preparing search index...

    Class HtzServer

    L1 construct for a Hetzner Server resource.

    Manages a Hetzner Cloud Server.

    Hierarchy

    • ProviderResource
      • HtzServer
    Index

    Constructors

    Properties

    attrCrn: IResolvable

    An IResolvable that resolves to the CRN (Cloud Resource Name) of this resource. Returns a { ref, attr } token that the engine resolves at deploy time to the actual CRN string constructed by the handler.

    attrServerId: IResolvable

    The serverId attribute of this resource. Resolves to { ref: logicalId, attr: 'serverId' } at synthesis time.

    automount?: boolean
    datacenter?: string
    firewalls?: ServerFirewall[]
    image: string
    labels?: Record<string, string>
    location?: Location
    logicalId: string

    Stable logical ID for this resource, derived from its construct node path. Combines a human-readable prefix with an 8-character SHA-256 hash suffix, guaranteeing uniqueness across renames/refactors.

    Format: <PathSegments><HASH8> — e.g. MyStackWebServer3A1B2C3D

    Used as the key in the synthesized stack JSON and as the target of cross-resource { ref, attr } references.

    name: string
    networks?: (number | IResolvable)[]
    node: Node

    The tree node.

    placementGroupId?: number | IResolvable
    properties?: Record<string, PropertyValue>

    The raw (pre-resolution) properties for this resource. Used by the base renderProperties() implementation.

    publicNet?: ServerPublicNet
    resourceOptions: IProviderResourceOptions

    Options for this resource, such as condition, deletion policy, etc.

    serverType: ServerType
    sshKeys?: (string | IResolvable)[]
    startAfterCreate?: boolean
    type: string

    The resource type identifier.

    userData?: string
    volumes?: (number | IResolvable)[]
    RESOURCE_TYPE_NAME: "Hetzner::Compute::Server" = 'Hetzner::Compute::Server'

    The CloudFormation-style type name for this resource.

    Accessors

    • get ref(): IResolvable

      Returns an IResolvable that resolves to { ref: logicalId } — a whole-object reference token used by file-rendering synthesizers (e.g. YamlFileSynthesizer) to compose this resource's full output into a parent resource's array field.

      Unlike getAtt(), no attr is included. The synthesizer resolves the token to the complete resolved data of the referenced resource.

      Returns IResolvable

    Methods

    • Adds an explicit dependency on another ProviderResource. This ensures the dependent resource is synthesized after this one.

      Parameters

      • resource: ProviderResource

      Returns void

    • Applies a removal policy to this resource. Maps the high-level RemovalPolicy enum to provider-level deletion/replace policies.

      Parameters

      • policy: RemovalPolicy | undefined
      • Optionaloptions: RemovalPolicyOptions

      Returns void

    • Returns an IResolvable that resolves to a { ref, attr } token referencing an output attribute of this resource.

      Used by L1 constructs to expose cross-resource reference attributes (e.g. attrNetworkId, attrServerId) that the engine resolves at deploy time by reading the named output from the created resource.

      Parameters

      • attr: string

        The attribute name to reference (e.g. 'networkId').

      Returns IResolvable

    • Returns the properties object used during synthesis.

      The base implementation returns this.properties (the value passed to the constructor). L1 subclasses generated by spec-to-cdkx override this method to build the properties object from their own public mutable members, following the same pattern as AWS CDK's cfnProperties getter.

      Override this in custom L1s to expose mutable properties that can be mutated post-construction and still be correctly reflected at synthesis time.

      Returns Record<string, PropertyValue>

    • Synthesizes this resource to a plain JSON-serializable object.

      Uses the resolver pipeline from the root App to resolve all Lazy values and IResolvable tokens within the properties tree. The resolved properties are then sanitized (null/undefined removed, unresolved tokens detected and thrown).

      The dependsOn field is always computed and emitted when non-empty. It is the deduplicated union of:

      • Logical IDs from explicit addDependency() calls.
      • Logical IDs referenced by { ref, attr } tokens found anywhere in the resolved (sanitized) properties tree.

      Output shape — a single-key object keyed by the resource's logicalId:

      {
      "MyStackWebServer3A1B2C3D": {
      "type": "hetzner::Server",
      "properties": { ... resolved properties ... },
      "metadata": { "cdkx:path": "MyStack/WebServer/Resource" },
      "dependsOn": ["MyStackNetwork1A2B3C4D"]
      }
      }

      The dependsOn key is omitted when there are no dependencies.

      Returns Record<string, unknown>

    • Returns the raw (pre-resolution) output data for this resource.

      Used by file-rendering synthesizers (e.g. YamlFileSynthesizer) as the output shape instead of toJson(). Unlike toJson(), no resolution or sanitization is applied — { ref, attr } tokens remain as-is so that the synthesizer can inspect them for composition.

      Delegates to renderProperties(), so L1 subclasses that override renderProperties() automatically get the correct output here too.

      Returns unknown

    • Returns a string representation of this construct.

      Returns string

    • Applies one or more mixins to this construct.

      Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

      Parameters

      • ...mixins: IMixin[]

        The mixins to apply

      Returns IConstruct

      This construct for chaining

    • Checks if x is a construct.

      Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

      Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

      Parameters

      • x: any

        Any object

      Returns x is Construct

      true if x is an object created from a class which extends Construct.

    • Returns true if the given object is a ProviderResource instance.

      Parameters

      • this: void
      • x: unknown

      Returns x is ProviderResource