将 Output<string> 转换为 AssumeRolePolicy 的字符串

Convert Output<string> to string for AssumeRolePolicy

我正在尝试使用 F# 了解 pulumi,但我无法理解如何将从一种资源发出的输出值最终用于另一种资源。这是我的具体案例:

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)))
            )

我试图移植到 f#

的以下演练给了我很大的启发

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

当前构建项目告诉我:

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>'

如何使用 pulumi 将输出转换为输入?

有一个辅助函数io可以将输出转换为输入

AssumeRolePolicy = io adminRolePolicy

您需要引用 Pulumi.FSharp NuGet 包。

io source and a usage example