https://pulumi.com logo
#golang
Title
# golang
b

bright-ghost-66126

07/27/2020, 8:49 PM
the code that is generated from this using tf2pulummi
Copy code
resource "okta_policy_mfa" "blue-ocean" {
				name            = "Blue Ocean"
				status          = "ACTIVE"
				description     = "Blue Ocean"
				groups_included = ["abc"]
				priority        = okta_policy_mfa.svc.priority + 1
			  }
			  resource "okta_policy_mfa" "svc" {
				name            = "Service Accounts"
				status          = "ACTIVE"
				description     = ""
				groups_included = ["abc"]
				priority        = 1
			  }
looks like this
Copy code
import (
        	"<http://github.com/pulumi/pulumi-okta/sdk/v2/go/okta/policy|github.com/pulumi/pulumi-okta/sdk/v2/go/okta/policy>"
        	"<http://github.com/pulumi/pulumi/sdk/v2/go/pulumi|github.com/pulumi/pulumi/sdk/v2/go/pulumi>"
        )
        
        func main() {
        	pulumi.Run(func(ctx *pulumi.Context) error {
        		svc, err := policy.NewMfa(ctx, "svc", &policy.MfaArgs{
        			Name:        pulumi.String("Service Accounts"),
        			Status:      pulumi.String("ACTIVE"),
        			Description: pulumi.String(""),
        			GroupsIncludeds: pulumi.StringArray{
        				pulumi.String("abc"),
        			},
        			Priority: <http://pulumi.Int|pulumi.Int>(1),
        		})
        		if err != nil {
        			return err
        		}
        		_, err = policy.NewMfa(ctx, "blue_ocean", &policy.MfaArgs{
        			Name:        pulumi.String("Blue Ocean"),
        			Status:      pulumi.String("ACTIVE"),
        			Description: pulumi.String("Blue Ocean"),
        			GroupsIncludeds: pulumi.StringArray{
        				pulumi.String("abc"),
        			},
        			Priority: <http://pulumi.Int|pulumi.Int>(svc.Priority.ApplyT(func(priority int) (float64, error) {
        				return priority + 1, nil
        			}).(pulumi.Float64Output)),
        		})
        		if err != nil {
        			return err
        		}
        		return nil
        	})
        }
running this code results in this
Copy code
pulumi_okta [pulumi_okta.test]
/Users/jjayaweera/go/src/pulumi_okta/some_test.go:143:24: cannot convert svc.Priority.OutputState.ApplyT(func literal).(pulumi.Float64Output) (type pulumi.Float64Output) to type <http://pulumi.Int|pulumi.Int>
/Users/jjayaweera/go/src/pulumi_okta/some_test.go:144:21: cannot use priority + 1 (type int) as type float64 in return argument
FAIL	pulumi_okta [build failed]
FAIL
What is the correct syntax for this
Copy code
Priority: <http://pulumi.Int|pulumi.Int>(svc.Priority.ApplyT(func(priority int) (float64, error) {
        				return priority + 1, nil
        			}).(pulumi.Float64Output)),
l

lemon-agent-27707

07/27/2020, 9:30 PM
Sorry you're running into this. I think there's a bug in our type checker. I believe you should be able to do something like:
Copy code
Priority: svc.Priority.ApplyInt(func(priority int) (int, error) {
        				return priority + 1, nil
        			}),
👍 1
3 Views