Closed hazcod closed 1 year ago
Hi @hazcod and thanks for reporting this issue with our documentation. Looking closer at our API spec/docs, it looks like the type for the Subnetworks
field is []{RouterNatSubnetworkArgs}
. Ref: RouterNat Doc.
Could you update your Pulumi program to something like the following snippet and see if it works for you?
foo, bar := compute.NewRouterNat(ctx,
fmt.Sprintf("gke-%s-network-router-nat", clusterName),
&compute.RouterNatArgs{
Name: pulumi.String(fmt.Sprintf("gke-%s-network-router-nat", clusterName)),
NatIpAllocateOption: pulumi.String("MANUAL_ONLY"),
NatIps: pulumi.StringArray{natIP.ID()},
Region: pulumi.String("region"),
Router: router.ID(),
SourceSubnetworkIpRangesToNat: pulumi.String("LIST_OF_SUBNETWORKS"),
Subnetworks: []compute.RouterNatSubnetworkArgs{
{
Name: subnet.ID(),
SourceIpRangesToNats: pulumi.StringArray{
pulumi.String("ALL_IP_RANGES"),
},
},
},
},
)
In the meantime, I'll investigate why our examples are inaccurate.
Hi @rquitales , interestingly still the same:
Interestingly, I'm unable to reproduce the original issue locally. I was able to use compute.RouterNatSubnetworkArray
as the concrete type for the Subnetworks
field.
@hazcod Could you run pulumi about
in your Pulumi project folder so we can have a better understanding about your environment,
Here is a minimal repro code I created:
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
net, err := compute.NewNetwork(ctx, "net", nil)
if err != nil {
return err
}
// Create a new router
router, err := compute.NewRouter(ctx, "myrouter", &compute.RouterArgs{
Network: net.ID(),
Region: pulumi.String("us-central1"),
})
if err != nil {
return err
}
// Create a GCP subnetwork
subnet, err := compute.NewSubnetwork(ctx, "mysub", &compute.SubnetworkArgs{
Name: pulumi.String("mysub"),
Network: net.ID(),
IpCidrRange: pulumi.String("10.1.0.0/16"),
Region: pulumi.String("us-central1"),
})
if err != nil {
return err
}
// Create a new NAT
_, err = compute.NewRouterNat(ctx,
fmt.Sprintf("gke-%s-network-router-nat", "mycluster"),
&compute.RouterNatArgs{
Region: pulumi.String("us-central1"),
Router: router.Name,
NatIpAllocateOption: pulumi.String("AUTO_ONLY"),
SourceSubnetworkIpRangesToNat: pulumi.String("ALL_SUBNETWORKS_ALL_IP_RANGES"),
Subnetworks: compute.RouterNatSubnetworkArray{
&compute.RouterNatSubnetworkArgs{
Name: subnet.ID(),
SourceIpRangesToNats: pulumi.StringArray{
pulumi.String("ALL_IP_RANGES"),
},
},
},
})
if err != nil {
return err
}
ctx.Export("routerName", router.Name)
return nil
})
}
@rquitales I do not have the pulumi
cli, only the Go modules so far. Hmm. 🤔
@rquitales Having installed pulumi
via brew now:
% pulumi about
CLI
Version 3.77.1
Go Version go1.20.7
Go Compiler gc
Host
OS darwin
Version 13.5
Arch arm64
go.sum:
% cat go.sum | grep pulumi
github.com/pulumi/pulumi-gcp/sdk/v6 v6.61.0 h1:K8QHiQx5IvTBNRj8Go5XBu0Ol3NWDABN04Lzrd1T+uM=
github.com/pulumi/pulumi-gcp/sdk/v6 v6.61.0/go.mod h1:hcVycxkARvh/sylq8s8OMBJHJjFsOq5r+NcQekIa+fQ=
github.com/pulumi/pulumi/sdk/v3 v3.76.1 h1:ItfwcLvxAyX+Pl+BPgx+J5mhKF3/LWOMls/vneTXp9o=
github.com/pulumi/pulumi/sdk/v3 v3.76.1/go.mod h1:HiE9Wf+DVrg8Em1D6bxRCdDMsNkj8//vLCST73xH2Hc=
Same error after retrieving latest go module versions:
% cat go.sum | grep pulumi
github.com/pulumi/pulumi-gcp/sdk/v6 v6.62.0 h1:mHjyIp7JHd0oycBDArUrLoBQwUlIcEqr2Q03gNNN/8s=
github.com/pulumi/pulumi-gcp/sdk/v6 v6.62.0/go.mod h1:hcVycxkARvh/sylq8s8OMBJHJjFsOq5r+NcQekIa+fQ=
github.com/pulumi/pulumi/sdk/v3 v3.77.1 h1:DfMCVjtzaSYqpZmMmRdHA5i1vaD6zYsCkDmcZqojREI=
github.com/pulumi/pulumi/sdk/v3 v3.77.1/go.mod h1:FEFictCHoa8CYzKDSc0t9ErrNiaO9n7pChreLQLDH+M=
Any update on this one? Thank you.
Hi @hazcod. Making some modifications to get a self-contained program, this compiles for me:
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(run)
}
func run(ctx *pulumi.Context) error {
clusterName := "foo"
_, err := compute.NewRouterNat(ctx,
fmt.Sprintf("gke-%s-network-router-nat", clusterName),
&compute.RouterNatArgs{
Name: pulumi.String(fmt.Sprintf("gke-%s-network-router-nat", clusterName)),
NatIpAllocateOption: pulumi.String("MANUAL_ONLY"),
NatIps: pulumi.StringArray{},
Region: pulumi.String("region"),
Router: nil,
SourceSubnetworkIpRangesToNat: pulumi.String("LIST_OF_SUBNETWORKS"),
Subnetworks: compute.RouterNatSubnetworkArray{
&compute.RouterNatSubnetworkArgs{
Name: nil,
SourceIpRangesToNats: pulumi.StringArray{
pulumi.String("ALL_IP_RANGES"),
},
},
},
},
)
return err
}
Does the above work for you? If not, can you please post the compilation error that you're getting?
Thanks!
Hi @iwahbe , this compiles! Thank you! I'm not sure yet what was the issue..
What happened?
I get an
Unresolved type RouterNatSubnetworkArray
when trying to setcompute.RouterNatArgs.Subnetworks
ingithub.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute
.Expected Behavior
Works when looking at the docs.
Steps to reproduce
Try to compile following code:
Output of
pulumi about
go.mod:
Additional context
Interestingly,
RouterNatSubnetworkArrayInput
is also not recognized during compilation inrouterNat.go
.Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).