Hi guys, trying to use generics here pulumi/exampl...
# golang
v
Hi guys, trying to use generics here pulumi/examples/aws-go-webserver this compiles but then does not run, sorry, am I missing something obvious? reading source code of pulumix has not helped (yet hehe)
Copy code
package main

import (
	"<http://github.com/pulumi/pulumi-aws/sdk/v6/go/aws/x/ec2|github.com/pulumi/pulumi-aws/sdk/v6/go/aws/x/ec2>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumix|github.com/pulumi/pulumi/sdk/v3/go/pulumix>"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a new security group for port 80.
		arg := ec2.SecurityGroupIngressArgs{
			Protocol:   pulumi.String("tcp"),
			FromPort:   <http://pulumi.Int|pulumi.Int>(80),
			ToPort:     <http://pulumi.Int|pulumi.Int>(80),
			CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
		}
		ingress := pulumix.Array[*ec2.SecurityGroupIngressArgs]{
			pulumix.Ptr(arg),
		}
		group, err := ec2.NewSecurityGroup(ctx, "web-secgrp", &ec2.SecurityGroupArgs{
			Ingress: ingress,
		})
		if err != nil {
			return err
		}

		// Get the ID for the latest Amazon Linux AMI.
		mostRecent := true
		ami, err := ec2.LookupAmi(ctx, &ec2.LookupAmiArgs{
			Filters: []ec2.GetAmiFilter{
				{
					Name:   "name",
					Values: []string{"amzn-ami-hvm-*-x86_64-ebs"},
				},
			},
			Owners:     []string{"137112412989"},
			MostRecent: &mostRecent,
		})
		if err != nil {
			return err
		}

		// Create a simple web server using the startup script for the instance.
		srv, err := ec2.NewInstance(ctx, "web-server-www", &ec2.InstanceArgs{
			Tags:                pulumi.StringMap{"Name": pulumi.String("web-server-www")},
			InstanceType:        pulumix.Ptr("t2.micro"), // t2.micro is available in the AWS free tier.
			VpcSecurityGroupIds: pulumi.StringArray{group.ID()},
			Ami:                 pulumix.Ptr(ami.Id),
			UserData: pulumix.Ptr(`#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &`),
		})

		// Export the resulting server's IP address and DNS name.
		ctx.Export("publicIp", srv.PublicIp)
		ctx.Export("publicHostName", srv.PublicDns)
		return nil
	})
}
fails with
Copy code
$ pulumi up
Previewing update (dev)

View in Browser (Ctrl+O): <https://app.pulumi.com/wildfluss/page-to-pdf-infra/dev/previews/37bb8fa8-c73e-4789-b952-f3ebf8e939ce>

     Type                 Name                   Plan       Info
 +   pulumi:pulumi:Stack  page-to-pdf-infra-dev  create     1 error

Diagnostics:
  pulumi:pulumi:Stack (page-to-pdf-infra-dev):
    error: an unhandled error occurred: program failed:
    waiting for RPCs: marshaling properties: awaiting input property "ingress": cannot marshal an input of type pulumix.Array[*<http://github.com/pulumi/pulumi-aws/sdk/v6/go/aws/x/ec2.SecurityGroupIngressArgs|github.com/pulumi/pulumi-aws/sdk/v6/go/aws/x/ec2.SecurityGroupIngressArgs>] with element type []*ec2.SecurityGroupIngressArgs as a value of type []ec2.SecurityGroupIngress