rough-ice-18151
03/22/2025, 12:32 AMKmsKeyId
StringPtrInput
in the VolumeArgs
. Now, I've updated my code and I'm passing a freshly initialized StringPtrOutput
with a nil value, but this is causing a diff between my old version and new one, which will delete and re-create my volume.
I'm guessing that this diff happens because I first passed in nothing, now I'm actually passing an output, even though its value is nil
. Is that correct?
If so, I'm trying to handle this with a resource transform, but how can I check the value of this output and delete it in an ApplyT and pass that back into the ResourceTransformResult
This code doesn't compile, but hopefully it shows what I'm trying to do
pulumi.Transforms([]pulumi.ResourceTransform{
func(ctx context.Context, rta *pulumi.ResourceTransformArgs) *pulumi.ResourceTransformResult {
newProps := rta.Props.ToMapOutput().ApplyT(func(props map[string]any) map[string]any {
if val, ok := props["kmsKeyId"]; ok && val == nil {
delete(newProps, "kmsKeyId")
}
return props
}).(pulumi.MapOutput)
return &pulumi.ResourceTransformResult{
Props: newProps,
Opts: rta.Opts,
}
},
}),
or maybe more simply put, how can I modify rta.Props
and return the result in a transform?rough-ice-18151
03/22/2025, 12:54 AMechoing-dinner-19531
03/22/2025, 11:19 AMrough-ice-18151
03/22/2025, 12:56 PMrough-ice-18151
03/22/2025, 1:43 PMechoing-dinner-19531
03/22/2025, 2:33 PMrough-ice-18151
03/24/2025, 1:29 PMechoing-dinner-19531
03/24/2025, 1:29 PMrough-ice-18151
03/24/2025, 2:55 PMkmsKeyId: null
, and re-imported the state.
But I’m still getting a diff when I have a nil value for KmsKeyId
in the StringPtrOutput
.. am I missing a step?echoing-dinner-19531
03/24/2025, 3:00 PMrough-ice-18151
03/24/2025, 3:01 PMkmsKeyId: ""
.. should I make that nil
too?rough-ice-18151
03/24/2025, 3:01 PMrough-ice-18151
03/24/2025, 3:31 PM"propertyDependencies": {
"availabilityZone": [],
"encrypted": [],
"iops": [],
"kmsKeyId": [],
"size": [],
"tags": [],
"throughput": [],
"type": []
},
rough-ice-18151
03/24/2025, 3:31 PMrough-ice-18151
03/24/2025, 3:33 PMrough-ice-18151
03/24/2025, 6:14 PMkmsKeyId := pulumi.StringPtrFromPtr(nil)
which just returns nil
... now we're all good!rough-ice-18151
03/24/2025, 6:14 PMechoing-dinner-19531
03/24/2025, 6:28 PM