Help us shape the future of Go! Take the 2026 Go Developer Survey

nat_static_mapping

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package nat_static_mapping implements the hyperv_nat_static_mapping resource. Wraps the nat_static_mapping/{get,new,set,remove}.ps1 contract via the typed hyperv.Client. Composes with hyperv_virtual_switch's NAT type (or any pre-existing NetNat instance) to build a Windows-native reverse proxy in front of one or more VMs on a private network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() resource.Resource

New is the framework factory.

Types

type FirewallRuleModel

type FirewallRuleModel struct {
	Enabled types.Bool   `tfsdk:"enabled"`
	Name    types.String `tfsdk:"name"`
	Profile types.String `tfsdk:"profile"`
}

FirewallRuleModel is the nested-attribute model. Carried through types.Object on the parent Model so the framework can serialize it. Defaults applied at the schema layer (enabled=true, profile=Any); name derived in resource.go from protocol + external_port when unset.

type Model

type Model struct {
	ID            types.String `tfsdk:"id"`
	NatName       types.String `tfsdk:"nat_name"`
	Protocol      types.String `tfsdk:"protocol"`
	AddressFamily types.String `tfsdk:"address_family"`
	ExternalIP    types.String `tfsdk:"external_ip"`
	ExternalPort  types.Int64  `tfsdk:"external_port"`
	InternalIP    types.String `tfsdk:"internal_ip"`
	InternalPort  types.Int64  `tfsdk:"internal_port"`
	FirewallRule  types.Object `tfsdk:"firewall_rule"`
}

Model is the tfsdk-bound struct backing the resource state. Field tags align with schema.go attribute names; conversion to/from the typed hyperv.NatStaticMapping DTO lives in resource.go. The lookup tuple (NatName, Protocol, ExternalIP, ExternalPort) is RequiresReplace at the schema layer, since it identifies the mapping uniquely and Hyper-V has no rename; internal_ip / internal_port and the firewall sub-attributes are in-place mutable.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Resource implements hyperv_nat_static_mapping.

func (*Resource) Configure

Configure stashes the typed Hyper-V client built by the provider's Configure pass. Skips when ProviderData is nil (validate-time invocation before the provider has resolved its config).

func (*Resource) Create

Create runs new.ps1 with the plan's attributes and writes the post-create read result back to state.

func (*Resource) Delete

Delete runs remove.ps1. ErrNotFound is treated as success -- the mapping is already gone, no need to error.

func (*Resource) ImportState

ImportState parses the composite identifier and seeds the lookup tuple in state. The 5-segment form is for a non-default firewall rule name, since Read can't locate a rule without already knowing it; the 4-segment form derives it instead. The stored `id` always keeps the 4-segment form: a stable identifier, not the import-only firewall name.

<nat_name>:<protocol>:<external_ip>:<external_port>
<nat_name>:<protocol>:<external_ip>:<external_port>:<firewall_rule_name>

func (*Resource) Metadata

Metadata sets the resource's TF type name.

func (*Resource) Read

Read fetches the current state via get.ps1 and reconciles it. ErrNotFound -> RemoveResource so Terraform plans recreate.

func (*Resource) Schema

Schema returns the locked-in schema (see schema.go).

func (*Resource) Update

Update runs set.ps1 with the plan's mutable attributes (internal_ip, internal_port, firewall_rule.{enabled, profile}) and writes the post-update read result back. The lookup tuple (nat_name, protocol, external_ip, external_port, firewall_rule.name) is RequiresReplace at the schema layer, so a change there forces destroy+recreate instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL