OpenMCF logoOpenMCF

Loading...

AWS Network Load Balancer

Deploys an AWS Network Load Balancer with bundled listeners and target groups, optional static IP addresses via Elastic IP allocation, TLS termination, and Route53 DNS record management. The component operates at Layer 4 (TCP/UDP/TLS) and requires at least one subnet mapping and one listener.

What Gets Created

When you deploy an AwsNetworkLoadBalancer resource, OpenMCF provisions:

  • Network Load Balancer — an aws_lb resource of type network, placed in the specified subnets via subnet mappings with attached security groups (optional), cross-zone load balancing configuration, and DNS client routing policy
  • Target Groups — one aws_lb_target_group per listener, configured with the specified protocol, port, target type, health check, deregistration delay, and connection settings (preserve client IP, Proxy Protocol v2, connection termination, source IP stickiness)
  • Listeners — one aws_lb_listener per spec listener, forwarding traffic to its corresponding target group with optional TLS configuration (certificate, SSL policy, ALPN policy) and TCP idle timeout
  • Route53 A Records — created only when DNS is enabled, one alias record per hostname pointing to the NLB's DNS name with target health evaluation enabled

Prerequisites

  • AWS credentials configured via environment variables or OpenMCF provider config
  • At least one subnet in a VPC (public subnets for internet-facing, private for internal). AWS recommends two or more across Availability Zones for high availability
  • An Elastic IP allocation ID per subnet if you need static public IP addresses (internet-facing NLBs only)
  • An ACM certificate ARN if enabling TLS termination on a listener
  • A Route53 hosted zone if enabling DNS management
  • A security group if you want to filter inbound traffic (optional for NLB, unlike ALB)

Quick Start

Create a file nlb.yaml:

apiVersion: aws.openmcf.org/v1
kind: AwsNetworkLoadBalancer
metadata:
  name: my-nlb
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.AwsNetworkLoadBalancer.my-nlb
spec:
  region: us-west-2
  subnetMappings:
    - subnetId: subnet-0a1b2c3d4e5f00001
    - subnetId: subnet-0a1b2c3d4e5f00002
  listeners:
    - name: tcp-80
      port: 80
      protocol: TCP
      targetGroup:
        port: 80
        protocol: TCP

Deploy:

openmcf apply -f nlb.yaml

This creates an internet-facing NLB with a TCP listener on port 80 forwarding to a target group on port 80, deployed across two subnets.

Configuration Reference

Required Fields

FieldTypeDescriptionValidation
regionstringAWS region where the Network Load Balancer will be created (e.g., us-west-2, eu-west-1).Required; non-empty
subnetMappingsobject[]Subnet mappings defining where NLB nodes are placed and optional static IPsMinimum 1 item required
subnetMappings[].subnetIdstringSubnet ID for the NLB node. Can reference an AwsVpc resource via valueFromRequired
listenersobject[]Listener configurations with inline target groupsMinimum 1 item required
listeners[].namestringUnique name for the listener, used as key in output mapsRequired. Lowercase alphanumeric and hyphens, starts with letter, max 63 chars
listeners[].portintPort the listener accepts traffic onRequired. Range: 1–65535
listeners[].protocolstringListener protocolRequired. One of: TCP, UDP, TLS, TCP_UDP
listeners[].targetGroupobjectTarget group configuration for this listenerRequired
listeners[].targetGroup.portintPort to route traffic to on targetsRequired. Range: 1–65535
listeners[].targetGroup.protocolstringProtocol for communication with targetsRequired. One of: TCP, UDP, TLS, TCP_UDP

Optional Fields

FieldTypeDefaultDescription
subnetMappings[].allocationIdstring—Elastic IP allocation ID for a static public IP on this NLB node. Internet-facing only.
subnetMappings[].privateIpv4Addressstring—Specific private IP for the NLB node. Internal NLBs only.
securityGroupsstring[][]Security group IDs. Optional for NLB. Can reference AwsSecurityGroup via valueFrom.
internalboolfalseWhen true, creates an internal NLB accessible only within the VPC.
deleteProtectionEnabledboolfalsePrevents accidental deletion when enabled.
crossZoneLoadBalancingEnabledboolfalseDistributes traffic evenly across all targets in all AZs.
ipAddressTypestringipv4IP address type. One of: ipv4, dualstack.
dnsRecordClientRoutingPolicystringany_availability_zoneDNS routing policy. One of: any_availability_zone, availability_zone_affinity, partial_availability_zone_affinity.
listeners[].tlsobject—TLS configuration. Required when protocol is TLS.
listeners[].tls.certificateArnstring—ACM certificate ARN for TLS termination. Can reference AwsCertManagerCert via valueFrom.
listeners[].tls.sslPolicystringAWS defaultTLS security policy (e.g., ELBSecurityPolicy-TLS13-1-2-2021-06).
listeners[].tcpIdleTimeoutSecondsint350TCP idle timeout. Only valid for TCP protocol. Range: 60–6000.
listeners[].alpnPolicystring—ALPN policy. Only valid for TLS protocol. One of: HTTP1Only, HTTP2Only, HTTP2Optional, HTTP2Preferred, None.
listeners[].targetGroup.targetTypestringinstanceTarget type. One of: instance, ip, alb.
listeners[].targetGroup.healthCheckobjectTCP on traffic-portHealth check configuration.
listeners[].targetGroup.healthCheck.protocolstringTCPHealth check protocol. One of: TCP, HTTP, HTTPS.
listeners[].targetGroup.healthCheck.portstringtraffic-portHealth check port. traffic-port or 1–65535.
listeners[].targetGroup.healthCheck.pathstring/Path for HTTP/HTTPS health checks. Required when protocol is HTTP or HTTPS.
listeners[].targetGroup.healthCheck.healthyThresholdint3Consecutive successes before healthy. Range: 2–10.
listeners[].targetGroup.healthCheck.unhealthyThresholdint3Consecutive failures before unhealthy. Range: 2–10.
listeners[].targetGroup.healthCheck.intervalSecondsint30Seconds between health checks. Range: 5–300.
listeners[].targetGroup.healthCheck.timeoutSecondsint10Seconds before timeout. Range: 2–120.
listeners[].targetGroup.healthCheck.matcherstring200-399HTTP response codes for healthy. Only for HTTP/HTTPS.
listeners[].targetGroup.deregistrationDelaySecondsint300Seconds to wait before deregistering draining targets. Range: 0–3600.
listeners[].targetGroup.preserveClientIpboolfalsePreserve original client IP in the IP header.
listeners[].targetGroup.proxyProtocolV2boolfalseEnable Proxy Protocol v2 header with client metadata.
listeners[].targetGroup.connectionTerminationboolfalseTerminate connections on deregistration delay expiry.
listeners[].targetGroup.stickinessEnabledboolfalseSource-IP-based sticky sessions.
dns.enabledboolfalseEnable Route53 DNS record creation.
dns.route53ZoneIdstring—Route53 hosted zone ID. Can reference AwsRoute53Zone via valueFrom.
dns.hostnamesstring[][]Domain names to point to the NLB. Must be unique.

Examples

Internal TCP NLB

An NLB accessible only within the VPC for internal microservice communication:

apiVersion: aws.openmcf.org/v1
kind: AwsNetworkLoadBalancer
metadata:
  name: internal-tcp-nlb
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.AwsNetworkLoadBalancer.internal-tcp-nlb
spec:
  region: us-west-2
  subnetMappings:
    - subnetId: subnet-private-az1
    - subnetId: subnet-private-az2
  internal: true
  listeners:
    - name: tcp-8080
      port: 8080
      protocol: TCP
      targetGroup:
        port: 8080
        protocol: TCP
        targetType: ip

TLS Termination with ACM Certificate

Internet-facing NLB that terminates TLS and forwards plaintext TCP to application servers:

apiVersion: aws.openmcf.org/v1
kind: AwsNetworkLoadBalancer
metadata:
  name: tls-nlb
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.AwsNetworkLoadBalancer.tls-nlb
spec:
  region: us-east-1
  subnetMappings:
    - subnetId: subnet-public-az1
    - subnetId: subnet-public-az2
  deleteProtectionEnabled: true
  listeners:
    - name: tls-443
      port: 443
      protocol: TLS
      tls:
        certificateArn: arn:aws:acm:us-east-1:123456789012:certificate/abc-12345
        sslPolicy: ELBSecurityPolicy-TLS13-1-2-2021-06
      targetGroup:
        port: 8080
        protocol: TCP
        healthCheck:
          protocol: HTTP
          path: /health
          intervalSeconds: 10
          healthyThreshold: 3

Static IPs with Elastic IPs

Internet-facing NLB with static public IPs for firewall allowlisting:

apiVersion: aws.openmcf.org/v1
kind: AwsNetworkLoadBalancer
metadata:
  name: static-ip-nlb
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.AwsNetworkLoadBalancer.static-ip-nlb
spec:
  region: us-west-2
  subnetMappings:
    - subnetId: subnet-public-az1
      allocationId: eipalloc-abc123
    - subnetId: subnet-public-az2
      allocationId: eipalloc-def456
  crossZoneLoadBalancingEnabled: true
  listeners:
    - name: tcp-443
      port: 443
      protocol: TCP
      targetGroup:
        port: 443
        protocol: TCP
        preserveClientIp: true

Full-Featured with Foreign Key References

Production NLB referencing other OpenMCF-managed resources:

apiVersion: aws.openmcf.org/v1
kind: AwsNetworkLoadBalancer
metadata:
  name: prod-nlb
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: prod.AwsNetworkLoadBalancer.prod-nlb
spec:
  region: us-west-2
  subnetMappings:
    - subnetId:
        valueFrom:
          kind: AwsVpc
          name: prod-vpc
          field: status.outputs.public_subnets[0].id
      allocationId: eipalloc-prod-az1
    - subnetId:
        valueFrom:
          kind: AwsVpc
          name: prod-vpc
          field: status.outputs.public_subnets[1].id
      allocationId: eipalloc-prod-az2
  securityGroups:
    - valueFrom:
        kind: AwsSecurityGroup
        name: nlb-sg
        field: status.outputs.security_group_id
  deleteProtectionEnabled: true
  crossZoneLoadBalancingEnabled: true
  listeners:
    - name: tls-443
      port: 443
      protocol: TLS
      tls:
        certificateArn:
          valueFrom:
            kind: AwsCertManagerCert
            name: prod-cert
            field: status.outputs.cert_arn
        sslPolicy: ELBSecurityPolicy-TLS13-1-2-2021-06
      alpnPolicy: HTTP2Preferred
      targetGroup:
        port: 8443
        protocol: TCP
        targetType: ip
        deregistrationDelaySeconds: 60
        preserveClientIp: true
        connectionTermination: true
        healthCheck:
          protocol: HTTPS
          path: /healthz
          healthyThreshold: 3
          unhealthyThreshold: 3
          intervalSeconds: 10
          timeoutSeconds: 6
          matcher: "200"
  dns:
    enabled: true
    route53ZoneId:
      valueFrom:
        kind: AwsRoute53Zone
        name: prod-zone
        field: status.outputs.zone_id
    hostnames:
      - api.example.com

Stack Outputs

After deployment, the following outputs are available in status.outputs:

OutputTypeDescription
load_balancer_arnstringARN of the Network Load Balancer
load_balancer_namestringName assigned to the NLB (may differ from metadata.name)
load_balancer_dns_namestringDNS name assigned by AWS (e.g., my-nlb-abc123.elb.us-east-1.amazonaws.com)
load_balancer_hosted_zone_idstringRoute53 hosted zone ID for the NLB's DNS entry, used for creating alias records
listener_arnsmap<string,string>Map of listener name to listener ARN (e.g., listener_arns.tls-443)
target_group_arnsmap<string,string>Map of listener name to target group ARN (e.g., target_group_arns.tls-443). Used by downstream services to register targets

Related Components

  • AwsVpc — provides the subnets for NLB placement via subnet mappings
  • AwsSecurityGroup — optional inbound traffic filtering for the NLB
  • AwsRoute53Zone — hosts the DNS zone for alias records
  • AwsCertManagerCert — provides the ACM certificate for TLS termination on listeners
  • AwsAlb — Application Load Balancer for Layer 7 (HTTP/HTTPS) routing; can be used as a target type for NLB-in-front-of-ALB patterns

Next article

AWS OpenSearch Domain

AWS OpenSearch Domain Deploys an Amazon OpenSearch Service domain with configurable cluster topology, EBS storage, encryption at rest and in transit, optional VPC placement, fine-grained access control, UltraWarm and cold storage tiers, log publishing to CloudWatch, and Auto-Tune optimization. What Gets Created When you deploy an AwsOpenSearchDomain resource, OpenMCF provisions: OpenSearch Domain — an opensearch.Domain with the specified engine version, cluster configuration, and tags derived...
Read next article
Presets
3 ready-to-deploy configurationsView presets →