fast-pager-93865
01/12/2022, 8:28 PMVpc:id: "vpcid1234"
If there is a VPC:id set then don’t run the first “Create New VPC” function, instead just use this string value as my VPC id for the “Create New Subnets” function. The issue I have run into is I am now dealing with a different type.
So for the “Create new subnets function to take in the VPC from the ID() method then I can have func like this:
func CreateSubnets(ctx *pulumi.Context, vpcID pulumi.IDOutput) { << vpcID is type pulumi.IDOoutput
//creates subnet(s)
Now for a string ID taken from the config object I need it to look like this
func CreateSubnets(ctx *pulumi.Context, vpcID string {
//creates subnet(s)
My question is am I tackling this the wrong way and if so what would be another approach? It feels like I am. I do of course appreciate this is a Go Type issue rather than a strictly Pulumi one :)little-cartoon-10569
01/12/2022, 8:35 PMfast-pager-93865
01/12/2022, 8:40 PMbillowy-army-68599
CreateSubnet
function take IDOutput
and then check if the vpc exists in the calling codelittle-cartoon-10569
01/12/2022, 8:42 PMbillowy-army-68599
var vpc *vpc
if config.CreateNewVPC {
// create a new VPC
vpc = aws.NewVPC
} else {
vpc = aws.LookupVPC
}
subnets = CreateSubnets(ctx, vpc.ID()
fast-pager-93865
01/12/2022, 8:47 PMbillowy-army-68599
fast-pager-93865
01/12/2022, 8:49 PMbillowy-army-68599
fast-pager-93865
01/12/2022, 8:55 PM