0
In case you hadn’t noticed, I’ve been on a bit of a kick with Pulumi and Go recently. There are two reasons for this. First, I have a number of “learning projects” (things that I decide I’d like to try or test) that would benefit greatly from the use of infrastructure as code. Second, I’ve been working on getting more familiar with Go. The idea of combining both those reasons by using Pulumi with Go seemed natural. Unfortunately, examples of using Pulumi with Go seem to be more limited than examples of using Pulumi with other languages, so in this post I’d like to share how to create an AWS ELB using Pulumi and Go.
Here’s the example code:
elb, err := elb.NewLoadBalancer(ctx, "elb", &elb.LoadBalancerArgs{
NamePrefix: pulumi.String(baseName),
CrossZoneLoadBalancing: pulumi.Bool(true),
AvailabilityZones: pulumi.StringArray(azNames),
Instances: pulumi.StringArray(cpNodeIds),
HealthCheck: &elb.LoadBalancerHealthCheckArgs{
HealthyThreshold: pulumi.Int(3),
Interval: pulumi.Int(30),
Target: pulumi.String("SSL:6443"),
UnhealthyThreshold: pulumi.Int(3),
Timeout: pulumi.Int(30),
},
Listeners: &elb.LoadBalancerListenerArray{
&elb.LoadBalancerListenerArgs{
InstancePort: pulumi.Int(6443),
InstanceProtocol: pulumi.String("TCP"),
LbPort: pulumi.Int(6443),
LbProtocol: pulumi.String("TCP"),
},
},
Tags: pulumi.StringMap{
"Name": pulumi.String(fmt.Sprintf("cp-elb-%s", baseName)),
k8sTag: pulumi.String("shared"),
},
})
You can probably infer from the code above that this Continue reading