https://pulumi.com logo
Title
e

elegant-zoo-39359

08/12/2022, 2:28 PM
Hi, is there a way of creating a nil
IntPtrOutput
? I've configured a helper function to take an
IntPtrInput
and then want to use
ApplyT
on this value to conditionally output a data structure if it is not nil, but the
ApplyT
fails with a NPE if it is nil. e.g. the following will fail if
size
is a
IntPtrInput
that is nil (at
ToIntPtrOutput()
). I could check for nil, but I don't think that would not work if
size
is an
IntPtrOutput
(because only its applied value would be nil).
res := size.ToIntPtrOutput().ApplyT(
		func(size *int) *ec2.LaunchTemplateBlockDeviceMapping {
Is there a nice way to generically handle this? I can use
pulumi.All
but that does not seem quite as elegant:
res := pulumi.All(size).ApplyT(
		func(args []interface{}) []ec2.LaunchTemplateBlockDeviceMapping {
			if args[0] != nil {
				size := args[0].(*int)