https://pulumi.com logo
Title
n

narrow-action-47255

07/27/2021, 4:03 PM
Hello! I'm pretty new to pulumi (it's awesome so far!) and I'm using AWS and Go. I'm trying to create a VPC and a subnet at the same time and am having trouble figuring out how to do it. I'm sure it's a simple issue. I'm not able to figure out what value to use for the
VpcId
in the
&ec2.SubnetArgs{}
and I'm not finding examples. The examples I have found in Go illustrate looking up an existing VPC, where other languages show the exact example I'm trying to accomplish. Example code follows. I have tried using different things for
VpcId
such as
platformVpc.ID()
(which is what I would use in
ctx.Export()
) and messed with
ApplyT
a bit, but I can't seem to figure out how to convert it to a string. Any help would be greatly appreciated!
// Create VPC
		platformVpc, err := ec2.NewVpc(ctx, "my-awesome-vpc", &ec2.VpcArgs{
			CidrBlock: pulumi.String("10.99.0.0/16"),
		})
		if err != nil {
			return err
		}

		platformVpcSubnetA, err := ec2.NewSubnet(ctx, "my-awesome-subnet-a", &ec2.SubnetArgs{
			VpcId:            pulumi.String("I DON'T KNOW WHAT TO PUT HERE"),
			CidrBlock:        pulumi.String("10.99.0.0/23"),
			AvailabilityZone: pulumi.StringPtr("us-east-1a"),
		})
		if err != nil {
			return err
		}
b

billowy-army-68599

07/27/2021, 4:05 PM
n

narrow-action-47255

07/27/2021, 4:08 PM
Thank you so much! I tried that, but must have had an unrelated syntax error at the time, because it failed too. That worked perfectly this time!
b

billowy-army-68599

07/27/2021, 4:09 PM
🎉