Anton Tayanovskyy

Anton Tayanovskyy

Software Engineer

Functions Now Accept Outputs

Functions Now Accept Outputs

Pulumi 3.17.1 makes it easier to compose function calls and resources. In practice you often need to call a function with a resource output. Previous versions of Pulumi required an apply to do this, which was unfortunate:

  • new Pulumi users would get stuck and ask for help as the solution was not obvious

  • experienced users found the code unpleasant, upvoting the relevant GitHub Issue

With Pulumi 3.17.1 you can now call functions directly with resource outputs without an extra apply. Every function now has an additional Output form that accepts Input-typed arguments and returns an Output-wrapped result.

For a quick example, here is how you can call aws.ecr.getCredentials with a registryId of type Output<string>:

const registryId: Output<string> = ...
getCredentialsOutput({registryId: registryId}): Output<GetCredentialsResult>
registry_id: Output[str] = ...
get_credentials_output(registry_id=registryId): Output[GetCredentialsResult]
var registryId StringOutput
var result GetCredentialsResultOutput
result = GetCredentialsOutput(ctx, GetCredentialsOutputArgs{
    RegistryId: result
})
Output<string> registryId;
GetCredentials.Invoke(new GetCredentialsInvokeArgs
{
   RegistryId = registryId
});

Read more →