https://pulumi.com logo
#aws
Title
# aws
f

fierce-toddler-53098

09/16/2021, 5:55 PM
Is there a sample to use v4 SDK (“github.com/pulumi/pulumi-aws/sdk/v4/go/aws/elb”) to create NLB and attach EC2 instances.
b

billowy-army-68599

09/16/2021, 6:10 PM
we don't have a sample for NLB specifically, but NLB should be very similar to ALB: https://github.com/pulumi/examples/search?q=alb
f

fierce-toddler-53098

09/16/2021, 7:02 PM
I could not find one for go.. I could use the v2 version to create the LB/TG and Listener but attachment seems to deprecated.. The option was to use v4 version but looks like the api seems to be diffrent.. I am looking NLB with go, but can use ALB as a sample to create the code…
b

billowy-army-68599

09/16/2021, 7:07 PM
@fierce-toddler-53098 are you using pulumi the elb namespace? ALBs and NLBs are in here: https://www.pulumi.com/docs/reference/pkg/aws/alb/loadbalancer/
Copy code
package main

import (
	"<http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/lb|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/lb>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := lb.NewLoadBalancer(ctx, "example", &lb.LoadBalancerArgs{
			LoadBalancerType: pulumi.String("network"),
			SubnetMappings: lb.LoadBalancerSubnetMappingArray{
				&lb.LoadBalancerSubnetMappingArgs{
					SubnetId:     pulumi.Any(aws_subnet.Example1.Id),
					AllocationId: pulumi.Any(aws_eip.Example1.Id),
				},
				&lb.LoadBalancerSubnetMappingArgs{
					SubnetId:     pulumi.Any(aws_subnet.Example2.Id),
					AllocationId: pulumi.Any(aws_eip.Example2.Id),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
note the
LoadBalancerType: pulumi.String("network")
f

fierce-toddler-53098

09/16/2021, 7:46 PM
Thanks looks like it work. Testing… Another question: does pulumi support new LB type called gateway loadbalancer
2 Views