@@ -70,6 +70,7 @@ func resourceEventHub() *pluginsdk.Resource {
7070 "message_retention" : {
7171 Type : pluginsdk .TypeInt ,
7272 Optional : true ,
73+ Computed : true ,
7374 ValidateFunc : validate .ValidateEventHubMessageRetentionCount ,
7475 ExactlyOneOf : []string {"retention_description" , "message_retention" },
7576 },
@@ -78,6 +79,7 @@ func resourceEventHub() *pluginsdk.Resource {
7879 Type : pluginsdk .TypeList ,
7980 Optional : true ,
8081 MaxItems : 1 ,
82+ Computed : true ,
8183 Elem : & pluginsdk.Resource {
8284 Schema : map [string ]* schema.Schema {
8385 "cleanup_policy" : {
@@ -331,16 +333,13 @@ func resourceEventHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
331333 eventhubStatus := eventhubs .EntityStatus (d .Get ("status" ).(string ))
332334 parameters := eventhubs.Eventhub {
333335 Properties : & eventhubs.EventhubProperties {
334- PartitionCount : utils .Int64 (int64 (d .Get ("partition_count" ).(int ))),
335- Status : & eventhubStatus ,
336- CaptureDescription : expandEventHubCaptureDescription (d ),
336+ PartitionCount : utils .Int64 (int64 (d .Get ("partition_count" ).(int ))),
337+ Status : & eventhubStatus ,
338+ MessageRetentionInDays : utils .Int64 (int64 (d .Get ("message_retention" ).(int ))),
339+ CaptureDescription : expandEventHubCaptureDescription (d ),
337340 },
338341 }
339342
340- if d .HasChange ("message_retention" ) {
341- parameters .Properties .MessageRetentionInDays = pointer .To (int64 (d .Get ("message_retention" ).(int )))
342- }
343-
344343 if d .HasChange ("capture_description" ) {
345344 parameters .Properties .CaptureDescription = expandEventHubCaptureDescription (d )
346345 }
@@ -398,14 +397,14 @@ func resourceEventHubRead(d *pluginsdk.ResourceData, meta interface{}) error {
398397 return err
399398 }
400399
400+ // TODO - the `props.RetentionDescription.TombstoneRetentionTimeInHours == nil` check can be removed when https://github.com/Azure/azure-rest-api-specs/issues/36018 is fixed
401+ if props .RetentionDescription == nil || props .RetentionDescription .TombstoneRetentionTimeInHours == nil {
402+ d .Set ("message_retention" , props .MessageRetentionInDays )
403+ }
401404 retentionDescription := flattenEventHubRetentionDescription (props .RetentionDescription )
402405 if err := d .Set ("retention_description" , retentionDescription ); err != nil {
403406 return err
404407 }
405-
406- if props .RetentionDescription == nil {
407- d .Set ("message_retention" , props .MessageRetentionInDays )
408- }
409408 }
410409 }
411410
0 commit comments