I'm not sure whether to post this in <#CRVK66N5U|>...
# golang
r
I'm not sure whether to post this in #CRVK66N5U or here, but since it's related to go types, I figure that I'd post here. I'm trying to run an
ApplyT
transform on a string output into an azure-native
network.SecurityRuleTypeArrayInput
, but keep on hitting an error:
Copy code
@ previewing update.....
    pulumi:pulumi:Stack byoc-byoc-test-az-2 running error: an unhandled error occurred: go inline source runtime error, an unhandled error occurred: applier's second input parameter must be assignable from interface {}, got string
    pulumi:pulumi:Stack byoc-byoc-test-az-2  1 error
Diagnostics:
  pulumi:pulumi:Stack (byoc-byoc-test-az-2):
    error: an unhandled error occurred: go inline source runtime error, an unhandled error occurred: applier's second input parameter must be assignable from interface {}, got string
    applier defined at /home/steven/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.143.0/go/pulumi/types_builtins.go:4977
My applier looks like this:
Copy code
ingressRules := sgArgs.BastionSubnetCidr.ToStringPtrOutput().ApplyT(func(bastionCidr *string) ([]network.SecurityRuleTypeArgs, error) {
		qdbRules, err := sgArgs.Ingress.AzureNsgRules()
		if err != nil {
			return nil, err
		}

		if bastionCidr != nil {
			qdbRules = append(qdbRules, network.SecurityRuleTypeArgs{
				Access:                   pulumi.String(network.SecurityRuleAccessAllow),
				DestinationAddressPrefix: pulumi.String("*"),
				DestinationPortRange:     pulumi.String("22"),
				Direction:                pulumi.String(network.SecurityRuleDirectionInbound),
				Name:                     pulumi.String("bastion ssh"),
				Priority:                 <http://pulumi.Int|pulumi.Int>(105),
				Protocol:                 pulumi.String(network.SecurityConfigurationRuleProtocolTcp),
				SourceAddressPrefix:      pulumi.String(*bastionCidr),
				SourcePortRange:          pulumi.String("*"),
			})
		}

		return qdbRules, nil

	}).(network.SecurityRuleTypeArrayInput)
where
sgArgs.Ingress.AzureNsgRules()
returns a
[]network.SecurityRuleTypeArgs
. I'm stumped because I'm not sure where the "applier's second input parameter" is. And why it's a
string
...
I think I got past this problem... I never assigned a value to an upstream input..
Well, now on to another problem, is it possible to return a complex type like
[]network.SecurityRuleTypeArgs
from
ApplyT
? So I can build an array conditionally based on the results of other outputs?
e
I think it should be fine to return any type from ApplyT, you might just have to do some casting to get it into the right Input-y type to assign it to a resource
r
Yep, that worked, just had my types mixed up. Thanks!