2

I am trying to get my head around pulumi using F# but I am unable to understand how to use Output values issued from one resource eventually into another resource. Here my specific case :

let infra() =

        let adminsName = "admins"
        let current =
            Output.Create<System.Threading.Tasks.Task<GetCallerIdentityResult>>(GetCallerIdentity.InvokeAsync()).Apply<GetCallerIdentityResult>(fun x->
                x
                |> Async.AwaitTask
                |> Async.RunSynchronously
            )

        let adminRoleName = sprintf "%s-eksClusterAdmin" adminsName

        let adminRolePolicy =
            current.Apply(fun id ->
                @"{
                  ""Version"": ""2012-10-17"",
                  ""Statement"": [
                    {
                      ""Action"": ""sts:AssumeRole"",
                      ""Principal"": {
                        ""AWS"": ""arn:aws:iam::" + id.AccountId + @":root""
                      },
                      ""Effect"": ""Allow"",
                      ""Sid"": """"
                    }
                  ]
                }"
            )


        let adminsIamRole =
            Role (adminRoleName,
                RoleArgs(AssumeRolePolicy= (adminRolePolicy.Apply(fun x -> x)))
            )

I have been heavily inspired by the following walkthrough that I am trying to port to f#

https://www.pulumi.com/docs/guides/crosswalk/kubernetes/identity/#create-an-iam-role-for-admins

Currently building the project tells me :

iam.fs(47,45): error FS0001: The type 'Output<string>' is not compatible with the type 'Input<string>'
iam.fs(47,44): error FS0193: Type constraint mismatch. The type     'Output<string>'    is not compatible with type    'Input<string>'

How can I cast Output into Input with pulumi ?

Yoann
  • 546
  • 4
  • 11
  • I'm not too familiar with this, but am trying to reproduce the compiler error. What Amazon packages and namespaces are you using? – Brian Berns Feb 19 '21 at 17:25

1 Answers1

3

There is a helper function io to convert an output to an input

AssumeRolePolicy = io adminRolePolicy

You need to reference the Pulumi.FSharp NuGet package.

See io source and a usage example.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • Thanks for you answer, I just found it out. I'll mark you as answer! I thank you for the link I was struggling with the documentation on pulumi site and it is not always obvious. – Yoann Feb 19 '21 at 17:39
  • By the way thanks for your post in f# advent calendar, this led me to trying out pulumi for my pet project... – Yoann Feb 19 '21 at 17:43
  • Great! Feel free to ping me on https://slack.pulumi.com/ or on twitter, happy to help another F#-er. – Mikhail Shilkov Feb 19 '21 at 17:44