https://pulumi.com logo
Title
g

gentle-knife-93855

11/02/2022, 3:42 AM
Hello, I have trouble passing Output of one resource as an input to another. I have created a Vpc in AWS using
kong_vpc, err := ec2.NewVpc(ctx, "kong-network", &ec2.VpcArgs{
			CidrBlock: pulumi.String("10.0.0.0/16"),
		})
		if err != nil {
			return err
		}
I am trying to fetch the VPC ID to pass it as an input for the subnet using
VpcId := kong_vpc.Id.ApplyT(func(vpc_id string) string {
			return vpc_id
		}).(pulumi.StringOutput)
But Pulumi throws the following error -
./main.go:17:21: kong_vpc.Id undefined (type *ec2.Vpc has no field or method Id)
The <https:/www.pulumi.com/registry/packages/aws/api-docs/ec2/vpc/#id_go|docs> mentions that
Id
is an Output of VPC
b

billowy-army-68599

11/02/2022, 2:49 PM
i believe that needs to be
ID()
g

gentle-knife-93855

11/02/2022, 2:54 PM
Thanks, that works. Does that mean any output can be referenced by capitalizing it and using it as a function? I see no reference of this in the docs
b

billowy-army-68599

11/02/2022, 3:22 PM
i think this is a doc error, i’ll file an issue
g

gentle-knife-93855

11/02/2022, 3:43 PM
It's the same case with Subnet, Security Group and probably more. The docs mentions
Id
but in usage, it is
ID()
b

billowy-army-68599

11/02/2022, 4:18 PM
all resources have an
ID()
it’s uppercase in Go
g

gentle-knife-93855

11/02/2022, 4:20 PM
Guess it needs a mention in the docs. Honest feedback is that it is difficult to find certain things for adopting pulumi with Go. I was looking for the syntax to use a boolean input in Go and found it 5 mins later in a third party blog (
pulumi.Bool
)
b

billowy-army-68599

11/02/2022, 4:21 PM
appreciate the feedback, we definitely know we need to improve here
s

salmon-account-74572

11/03/2022, 5:37 PM
When creating a subnet and needing to reference the VPC ID, you should be able to just pass
vpc.ID()
to the subnet’s
VpcId
input and be done with it.