@@ -706,7 +706,7 @@ func ResourceComposerEnvironment() *schema.Resource {
706
706
"task_logs_retention_config" : {
707
707
Type : schema .TypeList ,
708
708
Description : `Optional. The configuration setting for Task Logs.` ,
709
- Required : true ,
709
+ Optional : true ,
710
710
Elem : & schema.Resource {
711
711
Schema : map [string ]* schema.Schema {
712
712
"storage_mode" : {
@@ -718,6 +718,30 @@ func ResourceComposerEnvironment() *schema.Resource {
718
718
},
719
719
},
720
720
},
721
+ "airflow_metadata_retention_config" : {
722
+ Type : schema .TypeList ,
723
+ Description : `Optional. The configuration setting for database retention.` ,
724
+ Optional : true ,
725
+ Computed : true ,
726
+ Elem : & schema.Resource {
727
+ Schema : map [string ]* schema.Schema {
728
+ "retention_mode" : {
729
+ Type : schema .TypeString ,
730
+ Optional : true ,
731
+ Computed : true ,
732
+ ValidateFunc : validation .StringInSlice ([]string {"RETENTION_MODE_ENABLED" , "RETENTION_MODE_DISABLED" }, false ),
733
+ Description : `Whether database retention is enabled or not. This field is supported for Cloud Composer environments in composer 3 and newer.` ,
734
+ },
735
+ "retention_days" : {
736
+ Type : schema .TypeInt ,
737
+ Optional : true ,
738
+ Computed : true ,
739
+ ValidateFunc : validation .IntBetween (30 , 730 ),
740
+ Description : `How many days data should be retained for. This field is supported for Cloud Composer environments in composer 3 and newer.` ,
741
+ },
742
+ },
743
+ },
744
+ },
721
745
},
722
746
},
723
747
},
@@ -1470,6 +1494,22 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
1470
1494
return err
1471
1495
}
1472
1496
}
1497
+ if d .HasChange ("config.0.data_retention_config.0.airflow_metadata_retention_config" ) {
1498
+ patchObj := & composer.Environment {
1499
+ Config : & composer.EnvironmentConfig {
1500
+ DataRetentionConfig : & composer.DataRetentionConfig {
1501
+ AirflowMetadataRetentionConfig : & composer.AirflowMetadataRetentionPolicyConfig {},
1502
+ },
1503
+ },
1504
+ }
1505
+ if config != nil && config .DataRetentionConfig != nil && config .DataRetentionConfig .AirflowMetadataRetentionConfig != nil {
1506
+ patchObj .Config .DataRetentionConfig .AirflowMetadataRetentionConfig = config .DataRetentionConfig .AirflowMetadataRetentionConfig
1507
+ }
1508
+ err = resourceComposerEnvironmentPatchField ("config.DataRetentionConfig.AirflowMetadataRetentionConfig" , userAgent , patchObj , d , tfConfig )
1509
+ if err != nil {
1510
+ return err
1511
+ }
1512
+ }
1473
1513
if d .HasChange ("config.0.recovery_config.0.scheduled_snapshots_config" ) {
1474
1514
patchObj := & composer.Environment {Config : & composer.EnvironmentConfig {}}
1475
1515
if config != nil {
@@ -1766,6 +1806,7 @@ func flattenComposerEnvironmentConfigDataRetentionConfig(dataRetentionConfig *co
1766
1806
1767
1807
transformed := make (map [string ]interface {})
1768
1808
transformed ["task_logs_retention_config" ] = flattenComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig (dataRetentionConfig .TaskLogsRetentionConfig )
1809
+ transformed ["airflow_metadata_retention_config" ] = flattenComposerEnvironmentConfigDataRetentionConfigAirflowMetadataRetentionConfig (dataRetentionConfig .AirflowMetadataRetentionConfig )
1769
1810
1770
1811
return []interface {}{transformed }
1771
1812
}
@@ -1781,6 +1822,18 @@ func flattenComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(
1781
1822
return []interface {}{transformed }
1782
1823
}
1783
1824
1825
+ func flattenComposerEnvironmentConfigDataRetentionConfigAirflowMetadataRetentionConfig (airflowMetadataRetentionConfig * composer.AirflowMetadataRetentionPolicyConfig ) interface {} {
1826
+ if airflowMetadataRetentionConfig == nil {
1827
+ return nil
1828
+ }
1829
+
1830
+ transformed := make (map [string ]interface {})
1831
+ transformed ["retention_mode" ] = airflowMetadataRetentionConfig .RetentionMode
1832
+ transformed ["retention_days" ] = airflowMetadataRetentionConfig .RetentionDays
1833
+
1834
+ return []interface {}{transformed }
1835
+ }
1836
+
1784
1837
func flattenComposerEnvironmentConfigWorkloadsConfig (workloadsConfig * composer.WorkloadsConfig ) interface {} {
1785
1838
if workloadsConfig == nil {
1786
1839
return nil
@@ -2249,6 +2302,13 @@ func expandComposerEnvironmentConfigDataRetentionConfig(v interface{}, d *schema
2249
2302
}
2250
2303
transformed .TaskLogsRetentionConfig = transformedTaskLogsRetentionConfig
2251
2304
}
2305
+ if airflowMetadataRetentionConfig , ok := original ["airflow_metadata_retention_config" ]; ok {
2306
+ transformedAirflowMetadataRetentionConfig , err := expandComposerEnvironmentConfigDataRetentionConfigAirflowMetadataRetentionConfig (airflowMetadataRetentionConfig , d , config )
2307
+ if err != nil {
2308
+ return nil , err
2309
+ }
2310
+ transformed .AirflowMetadataRetentionConfig = transformedAirflowMetadataRetentionConfig
2311
+ }
2252
2312
2253
2313
return transformed , nil
2254
2314
}
@@ -2269,6 +2329,25 @@ func expandComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(v
2269
2329
return transformed , nil
2270
2330
}
2271
2331
2332
+ func expandComposerEnvironmentConfigDataRetentionConfigAirflowMetadataRetentionConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) (* composer.AirflowMetadataRetentionPolicyConfig , error ) {
2333
+ l := v .([]interface {})
2334
+ if len (l ) == 0 {
2335
+ return nil , nil
2336
+ }
2337
+ raw := l [0 ]
2338
+ original := raw .(map [string ]interface {})
2339
+ transformed := & composer.AirflowMetadataRetentionPolicyConfig {}
2340
+
2341
+ if v , ok := original ["retention_mode" ]; ok {
2342
+ transformed .RetentionMode = v .(string )
2343
+ }
2344
+ if v , ok := original ["retention_days" ]; ok {
2345
+ transformed .RetentionDays = int64 (v .(int ))
2346
+ }
2347
+
2348
+ return transformed , nil
2349
+ }
2350
+
2272
2351
func expandComposerEnvironmentConfigWorkloadsConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) (* composer.WorkloadsConfig , error ) {
2273
2352
l := v .([]interface {})
2274
2353
if len (l ) == 0 {
0 commit comments