hundreds-yacht-71603
01/12/2023, 12:59 PMstring
from `vpc.ID()`:
package main
import (
ec2Classic "<http://github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2>"
"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)
func main() {
vpc, err := ec2Classic.NewVpc(ctx, "vpc", &ec2Classic.VpcArgs{
CidrBlock: pulumi.String(cidrRange),
EnableDnsHostnames: pulumi.Bool(true),
EnableDnsSupport: pulumi.Bool(true),
}, opts...)
if err != nil {
return nil, err
}
ctx.Export("vpc", vpc)
rt, err := ec2Classic.LookupRouteTable(ctx, &ec2Classic.LookupRouteTableArgs{
// VpcId: pulumi.StringRef(fmt.Sprintf("%s", vpc.ID())),
Filters: []ec2Classic.GetRouteTableFilter{
{
Name: "vpc-id",
Values: []string{"vpc-0497cc4ca5e669e0c"}, // how do I get the actual string value from vpc.ID()??
},
{
Name: "association.main",
Values: []string{"true"},
},
},
})
}
miniature-musician-31262
01/12/2023, 3:05 PMvpc.ID()
is IDOutput
, a kind of Pulumi output, which means it can’t just be cast as a string, because its value is computed during the deployment (so it can’t be supplied to the lookup function as a “prompt” value). You can however obtain and use the computed string by converting the ID output to a string output, then doing the lookup in the string output’s .Apply()
--hundreds-yacht-71603
01/12/2023, 4:33 PMminiature-musician-31262
01/12/2023, 5:50 PM