@@ -638,8 +638,11 @@ func (k *azureNativeProvider) applyDefaults(ctx context.Context, urn string, ran
638
638
}
639
639
640
640
// Apply the apiVersion of this resource.
641
+ // Note that some resource types do not have an apiVersion property (e.g. storage:Blob).
641
642
if version .GetVersion ().Major >= 3 {
642
- news ["apiVersion" ] = resource .NewStringProperty (res .APIVersion )
643
+ if res .APIVersion != "" {
644
+ news ["apiVersion" ] = resource .NewStringProperty (res .APIVersion )
645
+ }
643
646
}
644
647
}
645
648
@@ -846,14 +849,14 @@ func (k *azureNativeProvider) Diff(_ context.Context, req *rpc.DiffRequest) (*rp
846
849
logging .V (9 ).Infof ("no __inputs found for '%s'" , urn )
847
850
}
848
851
849
-
852
+ // v2-to-v3 migration: apiVersion might be available in the old state and we use it to suppress spurious diffs.
850
853
migratedApiVersion := false
851
854
if version .GetVersion ().Major >= 3 {
852
855
if _ , ok := oldInputs ["apiVersion" ]; ! ok {
853
- // migration case: apiVersion might be available in the old state
854
- // and we use it to suppress spurious diffs
855
- oldInputs [ "apiVersion" ] = oldState [ "apiVersion" ]
856
- migratedApiVersion = true
856
+ if v , ok := oldState [ " apiVersion" ]; ok {
857
+ oldInputs [ "apiVersion" ] = v
858
+ migratedApiVersion = true
859
+ }
857
860
}
858
861
}
859
862
@@ -888,9 +891,9 @@ func (k *azureNativeProvider) Diff(_ context.Context, req *rpc.DiffRequest) (*rp
888
891
// Based on the detailed diff above, calculate the list of changes and replacements.
889
892
changes , replaces := calculateChangesAndReplacements (detailedDiff , oldInputs , newResInputs , oldState , * res )
890
893
891
- if version . GetVersion (). Major >= 3 && migratedApiVersion {
894
+ if migratedApiVersion {
892
895
if v , ok := detailedDiff ["apiVersion" ]; ok {
893
- // in this case, the diff is between the old state and the new inputs
896
+ // in this case, the diff is between the old state and the new inputs.
894
897
v .InputDiff = false
895
898
}
896
899
}
@@ -1648,8 +1651,10 @@ func checkpointObject(res *resources.AzureAPIResource, inputs resource.PropertyM
1648
1651
object ["__inputs" ] = resource .MakeSecret (resource .NewObjectProperty (inputs ))
1649
1652
}
1650
1653
1651
- // emit the actual apiversion as an output property
1652
- object ["apiVersion" ] = resource .NewStringProperty (res .APIVersion )
1654
+ // emit the actual apiversion as an output property, for resources that have an apiVersion property.
1655
+ if res .APIVersion != "" {
1656
+ object ["apiVersion" ] = resource .NewStringProperty (res .APIVersion )
1657
+ }
1653
1658
return object
1654
1659
}
1655
1660
0 commit comments