|
68 | 68 | "config.0.environment_size",
|
69 | 69 | "config.0.master_authorized_networks_config",
|
70 | 70 | "config.0.resilience_mode",
|
| 71 | + "config.0.data_retention_config", |
71 | 72 | }
|
72 | 73 |
|
73 | 74 | recoveryConfigKeys = []string{
|
@@ -623,6 +624,34 @@ func ResourceComposerEnvironment() *schema.Resource {
|
623 | 624 | },
|
624 | 625 | },
|
625 | 626 | },
|
| 627 | + |
| 628 | + "data_retention_config": { |
| 629 | + Type: schema.TypeList, |
| 630 | + Optional: true, |
| 631 | + Computed: true, |
| 632 | + AtLeastOneOf: composerConfigKeys, |
| 633 | + MaxItems: 1, |
| 634 | + Description: `The configuration setting for Airflow data retention mechanism. This field is supported for Cloud Composer environments in versions composer-2.0.32-airflow-2.1.4. or newer`, |
| 635 | + Elem: &schema.Resource{ |
| 636 | + Schema: map[string]*schema.Schema{ |
| 637 | + "task_logs_retention_config": { |
| 638 | + Type: schema.TypeList, |
| 639 | + Description: `Optional. The configuration setting for Task Logs.`, |
| 640 | + Required: true, |
| 641 | + Elem: &schema.Resource{ |
| 642 | + Schema: map[string]*schema.Schema{ |
| 643 | + "storage_mode": { |
| 644 | + Type: schema.TypeString, |
| 645 | + Optional: true, |
| 646 | + ValidateFunc: validation.StringInSlice([]string{"CLOUD_LOGGING_ONLY", "CLOUD_LOGGING_AND_CLOUD_STORAGE"}, false), |
| 647 | + Description: `Whether logs in cloud logging only is enabled or not. This field is supported for Cloud Composer environments in versions composer-2.0.32-airflow-2.1.4 and newer.`, |
| 648 | + }, |
| 649 | + }, |
| 650 | + }, |
| 651 | + }, |
| 652 | + }, |
| 653 | + }, |
| 654 | + }, |
626 | 655 | "workloads_config": {
|
627 | 656 | Type: schema.TypeList,
|
628 | 657 | Optional: true,
|
@@ -1178,7 +1207,22 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
|
1178 | 1207 | return err
|
1179 | 1208 | }
|
1180 | 1209 | }
|
1181 |
| - |
| 1210 | + if d.HasChange("config.0.data_retention_config.0.task_logs_retention_config.0.storage_mode") { |
| 1211 | + patchObj := &composer.Environment{ |
| 1212 | + Config: &composer.EnvironmentConfig{ |
| 1213 | + DataRetentionConfig: &composer.DataRetentionConfig{ |
| 1214 | + TaskLogsRetentionConfig: &composer.TaskLogsRetentionConfig{}, |
| 1215 | + }, |
| 1216 | + }, |
| 1217 | + } |
| 1218 | + if config != nil && config.DataRetentionConfig != nil && config.DataRetentionConfig.TaskLogsRetentionConfig != nil { |
| 1219 | + patchObj.Config.DataRetentionConfig.TaskLogsRetentionConfig.StorageMode = config.DataRetentionConfig.TaskLogsRetentionConfig.StorageMode |
| 1220 | + } |
| 1221 | + err = resourceComposerEnvironmentPatchField("config.DataRetentionConfig.TaskLogsRetentionConfig.StorageMode", userAgent, patchObj, d, tfConfig) |
| 1222 | + if err != nil { |
| 1223 | + return err |
| 1224 | + } |
| 1225 | + } |
1182 | 1226 | if d.HasChange("config.0.recovery_config.0.scheduled_snapshots_config") {
|
1183 | 1227 | patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
|
1184 | 1228 | if config != nil {
|
@@ -1356,6 +1400,7 @@ func flattenComposerEnvironmentConfig(envCfg *composer.EnvironmentConfig) interf
|
1356 | 1400 | transformed["web_server_config"] = flattenComposerEnvironmentConfigWebServerConfig(envCfg.WebServerConfig)
|
1357 | 1401 | transformed["encryption_config"] = flattenComposerEnvironmentConfigEncryptionConfig(envCfg.EncryptionConfig)
|
1358 | 1402 | transformed["maintenance_window"] = flattenComposerEnvironmentConfigMaintenanceWindow(envCfg.MaintenanceWindow)
|
| 1403 | + transformed["data_retention_config"] = flattenComposerEnvironmentConfigDataRetentionConfig(envCfg.DataRetentionConfig) |
1359 | 1404 | transformed["workloads_config"] = flattenComposerEnvironmentConfigWorkloadsConfig(envCfg.WorkloadsConfig)
|
1360 | 1405 | transformed["recovery_config"] = flattenComposerEnvironmentConfigRecoveryConfig(envCfg.RecoveryConfig)
|
1361 | 1406 | transformed["environment_size"] = envCfg.EnvironmentSize
|
@@ -1460,6 +1505,28 @@ func flattenComposerEnvironmentConfigMaintenanceWindow(maintenanceWindow *compos
|
1460 | 1505 | return []interface{}{transformed}
|
1461 | 1506 | }
|
1462 | 1507 |
|
| 1508 | +func flattenComposerEnvironmentConfigDataRetentionConfig(dataRetentionConfig *composer.DataRetentionConfig) interface{} { |
| 1509 | + if dataRetentionConfig == nil { |
| 1510 | + return nil |
| 1511 | + } |
| 1512 | + |
| 1513 | + transformed := make(map[string]interface{}) |
| 1514 | + transformed["task_logs_retention_config"] = flattenComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(dataRetentionConfig.TaskLogsRetentionConfig) |
| 1515 | + |
| 1516 | + return []interface{}{transformed} |
| 1517 | +} |
| 1518 | + |
| 1519 | +func flattenComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(taskLogsRetentionConfig *composer.TaskLogsRetentionConfig) interface{} { |
| 1520 | + if taskLogsRetentionConfig == nil { |
| 1521 | + return nil |
| 1522 | + } |
| 1523 | + |
| 1524 | + transformed := make(map[string]interface{}) |
| 1525 | + transformed["storage_mode"] = taskLogsRetentionConfig.StorageMode |
| 1526 | + |
| 1527 | + return []interface{}{transformed} |
| 1528 | +} |
| 1529 | + |
1463 | 1530 | func flattenComposerEnvironmentConfigWorkloadsConfig(workloadsConfig *composer.WorkloadsConfig) interface{} {
|
1464 | 1531 | if workloadsConfig == nil {
|
1465 | 1532 | return nil
|
@@ -1687,6 +1754,13 @@ func expandComposerEnvironmentConfig(v interface{}, d *schema.ResourceData, conf
|
1687 | 1754 | return nil, err
|
1688 | 1755 | }
|
1689 | 1756 | transformed.MaintenanceWindow = transformedMaintenanceWindow
|
| 1757 | + |
| 1758 | + transformedDataRetentionConfig, err := expandComposerEnvironmentConfigDataRetentionConfig(original["data_retention_config"], d, config) |
| 1759 | + if err != nil { |
| 1760 | + return nil, err |
| 1761 | + } |
| 1762 | + transformed.DataRetentionConfig = transformedDataRetentionConfig |
| 1763 | + |
1690 | 1764 | transformedWorkloadsConfig, err := expandComposerEnvironmentConfigWorkloadsConfig(original["workloads_config"], d, config)
|
1691 | 1765 | if err != nil {
|
1692 | 1766 | return nil, err
|
@@ -1854,6 +1928,42 @@ func expandComposerEnvironmentConfigMaintenanceWindow(v interface{}, d *schema.R
|
1854 | 1928 | return transformed, nil
|
1855 | 1929 | }
|
1856 | 1930 |
|
| 1931 | +func expandComposerEnvironmentConfigDataRetentionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) (*composer.DataRetentionConfig, error) { |
| 1932 | + l := v.([]interface{}) |
| 1933 | + if len(l) == 0 { |
| 1934 | + return nil, nil |
| 1935 | + } |
| 1936 | + raw := l[0] |
| 1937 | + original := raw.(map[string]interface{}) |
| 1938 | + transformed := &composer.DataRetentionConfig{} |
| 1939 | + |
| 1940 | + if taskLogsRetentionConfig, ok := original["task_logs_retention_config"]; ok { |
| 1941 | + transformedTaskLogsRetentionConfig, err := expandComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(taskLogsRetentionConfig, d, config) |
| 1942 | + if err != nil { |
| 1943 | + return nil, err |
| 1944 | + } |
| 1945 | + transformed.TaskLogsRetentionConfig = transformedTaskLogsRetentionConfig |
| 1946 | + } |
| 1947 | + |
| 1948 | + return transformed, nil |
| 1949 | +} |
| 1950 | + |
| 1951 | +func expandComposerEnvironmentConfigDataRetentionConfigTaskLogsRetentionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) (*composer.TaskLogsRetentionConfig, error) { |
| 1952 | + l := v.([]interface{}) |
| 1953 | + if len(l) == 0 { |
| 1954 | + return nil, nil |
| 1955 | + } |
| 1956 | + raw := l[0] |
| 1957 | + original := raw.(map[string]interface{}) |
| 1958 | + transformed := &composer.TaskLogsRetentionConfig{} |
| 1959 | + |
| 1960 | + if v, ok := original["storage_mode"]; ok { |
| 1961 | + transformed.StorageMode = v.(string) |
| 1962 | + } |
| 1963 | + |
| 1964 | + return transformed, nil |
| 1965 | +} |
| 1966 | + |
1857 | 1967 | func expandComposerEnvironmentConfigWorkloadsConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) (*composer.WorkloadsConfig, error) {
|
1858 | 1968 | l := v.([]interface{})
|
1859 | 1969 | if len(l) == 0 {
|
|
0 commit comments