我试图让我的头周围pulumi使用f#,但我无法理解如何使用输出值从一个资源发出最终进入另一个资源。下面是我的具体案例:
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将Output转换为Input ?
有一个辅助函数io
用于将输出转换为输入
AssumeRolePolicy = io adminRolePolicy
需要引用Pulumi.FSharp
NuGet包。
参见io
来源和使用示例。