delightful-camera-40926
03/25/2024, 5:07 PM{
"Comment": "Save Restriction - Trigger Deletion - Restore on Fail",
"StartAt": "ExportRestrictionData",
"States": {
"ExportRestrictionData": {
"Type": "Task",
"Resource": "${resource_A_ARN}"
}
}
}
The problem is, that reading this file and replacing this variable won't work using language native functions, as it's an Output type at the time.
I know you can circumvent the issue by creating resource B inside the .apply()
block, but is there a better way without a potential callback hell?
I was thinking about pulumi.interpolate
stale-twilight-75626
03/25/2024, 5:33 PMstale-twilight-75626
03/25/2024, 5:37 PMstale-twilight-75626
03/25/2024, 5:38 PMstale-twilight-75626
03/25/2024, 5:38 PMstale-twilight-75626
03/25/2024, 5:40 PMdelightful-camera-40926
03/26/2024, 2:24 PMString
type with the required function (replacePulumi
accepting Output as a replacement value)
The issue with this approach is that it only works once, as the return type is Output, so you can't chain .repalcePulumi()
And you can't extend Output, as it doesn't have a prototype (I'm using type script)
Unless there's a way?stale-twilight-75626
03/26/2024, 11:49 PMlimited-rainbow-51650
03/27/2024, 10:02 AMOutput
directly. You will have to pass a callback function to apply
. This is the inherent to the asynchronous nature of Pulumi where the program in your language host, and the provisioning by Pulumi run in different processes, communicating with each other via a local gRPC connection.delightful-camera-40926
03/27/2024, 10:33 AM.replace.Pulumi
extension is nothing more than a wrap around .replace
inside .apply()
callback returning output.
Would it be possible to extend the Output class to add additional functions? With casting later on.
From what I see, .d.ts defines it as an interface rather than a class. Is there a reason for this?
pulumi.interpolate
and pulumi.concat
are not enough for more complex string manipulations.
For example, chained .replace()