|
55 | 55 | "config.0.database_config",
|
56 | 56 | "config.0.web_server_config",
|
57 | 57 | "config.0.encryption_config",
|
| 58 | + "config.0.maintenance_window", |
58 | 59 | "config.0.workloads_config",
|
59 | 60 | "config.0.environment_size",
|
60 | 61 | }
|
@@ -310,7 +311,7 @@ func resourceComposerEnvironment() *schema.Resource {
|
310 | 311 | AtLeastOneOf: composerSoftwareConfigKeys,
|
311 | 312 | Elem: &schema.Schema{Type: schema.TypeString},
|
312 | 313 | ValidateFunc: validateComposerEnvironmentEnvVariables,
|
313 |
| - Description: `Additional environment variables to provide to the Apache Airflow schedulerf, worker, and webserver processes. Environment variable names must match the regular expression [a-zA-Z_][a-zA-Z0-9_]*. They cannot specify Apache Airflow software configuration overrides (they cannot match the regular expression AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+), and they cannot match any of the following reserved names: AIRFLOW_HOME C_FORCE_ROOT CONTAINER_NAME DAGS_FOLDER GCP_PROJECT GCS_BUCKET GKE_CLUSTER_NAME SQL_DATABASE SQL_INSTANCE SQL_PASSWORD SQL_PROJECT SQL_REGION SQL_USER.`, |
| 314 | + Description: `Additional environment variables to provide to the Apache Airflow scheduler, worker, and webserver processes. Environment variable names must match the regular expression [a-zA-Z_][a-zA-Z0-9_]*. They cannot specify Apache Airflow software configuration overrides (they cannot match the regular expression AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+), and they cannot match any of the following reserved names: AIRFLOW_HOME C_FORCE_ROOT CONTAINER_NAME DAGS_FOLDER GCP_PROJECT GCS_BUCKET GKE_CLUSTER_NAME SQL_DATABASE SQL_INSTANCE SQL_PASSWORD SQL_PROJECT SQL_REGION SQL_USER.`, |
314 | 315 | },
|
315 | 316 | "image_version": {
|
316 | 317 | Type: schema.TypeString,
|
@@ -463,7 +464,36 @@ func resourceComposerEnvironment() *schema.Resource {
|
463 | 464 | },
|
464 | 465 | },
|
465 | 466 | },
|
466 |
| - |
| 467 | + "maintenance_window": { |
| 468 | + Type: schema.TypeList, |
| 469 | + Optional: true, |
| 470 | + Computed: true, |
| 471 | + AtLeastOneOf: composerConfigKeys, |
| 472 | + MaxItems: 1, |
| 473 | + Description: `The configuration for Cloud Composer maintenance window.`, |
| 474 | + Elem: &schema.Resource{ |
| 475 | + Schema: map[string]*schema.Schema{ |
| 476 | + "start_time": { |
| 477 | + Type: schema.TypeString, |
| 478 | + Required: true, |
| 479 | + ForceNew: false, |
| 480 | + Description: `Start time of the first recurrence of the maintenance window.`, |
| 481 | + }, |
| 482 | + "end_time": { |
| 483 | + Type: schema.TypeString, |
| 484 | + Required: true, |
| 485 | + ForceNew: false, |
| 486 | + Description: `Maintenance window end time. It is used only to calculate the duration of the maintenance window. The value for end-time must be in the future, relative to 'start_time'.`, |
| 487 | + }, |
| 488 | + "recurrence": { |
| 489 | + Type: schema.TypeString, |
| 490 | + Required: true, |
| 491 | + ForceNew: false, |
| 492 | + Description: `Maintenance window recurrence. Format is a subset of RFC-5545 (https://tools.ietf.org/html/rfc5545) 'RRULE'. The only allowed values for 'FREQ' field are 'FREQ=DAILY' and 'FREQ=WEEKLY;BYDAY=...'. Example values: 'FREQ=WEEKLY;BYDAY=TU,WE', 'FREQ=DAILY'.`, |
| 493 | + }, |
| 494 | + }, |
| 495 | + }, |
| 496 | + }, |
467 | 497 | "workloads_config": {
|
468 | 498 | Type: schema.TypeList,
|
469 | 499 | Optional: true,
|
@@ -869,6 +899,17 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
|
869 | 899 | }
|
870 | 900 | }
|
871 | 901 |
|
| 902 | + if d.HasChange("config.0.maintenance_window") { |
| 903 | + patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}} |
| 904 | + if config != nil { |
| 905 | + patchObj.Config.MaintenanceWindow = config.MaintenanceWindow |
| 906 | + } |
| 907 | + err = resourceComposerEnvironmentPatchField("config.maintenanceWindow", userAgent, patchObj, d, tfConfig) |
| 908 | + if err != nil { |
| 909 | + return err |
| 910 | + } |
| 911 | + } |
| 912 | + |
872 | 913 | if d.HasChange("config.0.workloads_config") {
|
873 | 914 | patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
|
874 | 915 | if config != nil {
|
@@ -1011,6 +1052,7 @@ func flattenComposerEnvironmentConfig(envCfg *composer.EnvironmentConfig) interf
|
1011 | 1052 | transformed["database_config"] = flattenComposerEnvironmentConfigDatabaseConfig(envCfg.DatabaseConfig)
|
1012 | 1053 | transformed["web_server_config"] = flattenComposerEnvironmentConfigWebServerConfig(envCfg.WebServerConfig)
|
1013 | 1054 | transformed["encryption_config"] = flattenComposerEnvironmentConfigEncryptionConfig(envCfg.EncryptionConfig)
|
| 1055 | + transformed["maintenance_window"] = flattenComposerEnvironmentConfigMaintenanceWindow(envCfg.MaintenanceWindow) |
1014 | 1056 | transformed["workloads_config"] = flattenComposerEnvironmentConfigWorkloadsConfig(envCfg.WorkloadsConfig)
|
1015 | 1057 | transformed["environment_size"] = envCfg.EnvironmentSize
|
1016 | 1058 | return []interface{}{transformed}
|
@@ -1070,6 +1112,19 @@ func flattenComposerEnvironmentConfigEncryptionConfig(encryptionCfg *composer.En
|
1070 | 1112 | return []interface{}{transformed}
|
1071 | 1113 | }
|
1072 | 1114 |
|
| 1115 | +func flattenComposerEnvironmentConfigMaintenanceWindow(maintenanceWindow *composer.MaintenanceWindow) interface{} { |
| 1116 | + if maintenanceWindow == nil { |
| 1117 | + return nil |
| 1118 | + } |
| 1119 | + |
| 1120 | + transformed := make(map[string]interface{}) |
| 1121 | + transformed["start_time"] = maintenanceWindow.StartTime |
| 1122 | + transformed["end_time"] = maintenanceWindow.EndTime |
| 1123 | + transformed["recurrence"] = maintenanceWindow.Recurrence |
| 1124 | + |
| 1125 | + return []interface{}{transformed} |
| 1126 | +} |
| 1127 | + |
1073 | 1128 | func flattenComposerEnvironmentConfigWorkloadsConfig(workloadsConfig *composer.WorkloadsConfig) interface{} {
|
1074 | 1129 | if workloadsConfig == nil {
|
1075 | 1130 | return nil
|
@@ -1250,6 +1305,11 @@ func expandComposerEnvironmentConfig(v interface{}, d *schema.ResourceData, conf
|
1250 | 1305 | }
|
1251 | 1306 | transformed.EncryptionConfig = transformedEncryptionConfig
|
1252 | 1307 |
|
| 1308 | + transformedMaintenanceWindow, err := expandComposerEnvironmentConfigMaintenanceWindow(original["maintenance_window"], d, config) |
| 1309 | + if err != nil { |
| 1310 | + return nil, err |
| 1311 | + } |
| 1312 | + transformed.MaintenanceWindow = transformedMaintenanceWindow |
1253 | 1313 | transformedWorkloadsConfig, err := expandComposerEnvironmentConfigWorkloadsConfig(original["workloads_config"], d, config)
|
1254 | 1314 | if err != nil {
|
1255 | 1315 | return nil, err
|
@@ -1342,6 +1402,30 @@ func expandComposerEnvironmentConfigEncryptionConfig(v interface{}, d *schema.Re
|
1342 | 1402 | return transformed, nil
|
1343 | 1403 | }
|
1344 | 1404 |
|
| 1405 | +func expandComposerEnvironmentConfigMaintenanceWindow(v interface{}, d *schema.ResourceData, config *Config) (*composer.MaintenanceWindow, error) { |
| 1406 | + l := v.([]interface{}) |
| 1407 | + if len(l) == 0 { |
| 1408 | + return nil, nil |
| 1409 | + } |
| 1410 | + raw := l[0] |
| 1411 | + original := raw.(map[string]interface{}) |
| 1412 | + transformed := &composer.MaintenanceWindow{} |
| 1413 | + |
| 1414 | + if v, ok := original["start_time"]; ok { |
| 1415 | + transformed.StartTime = v.(string) |
| 1416 | + } |
| 1417 | + |
| 1418 | + if v, ok := original["end_time"]; ok { |
| 1419 | + transformed.EndTime = v.(string) |
| 1420 | + } |
| 1421 | + |
| 1422 | + if v, ok := original["recurrence"]; ok { |
| 1423 | + transformed.Recurrence = v.(string) |
| 1424 | + } |
| 1425 | + |
| 1426 | + return transformed, nil |
| 1427 | +} |
| 1428 | + |
1345 | 1429 | func expandComposerEnvironmentConfigWorkloadsConfig(v interface{}, d *schema.ResourceData, config *Config) (*composer.WorkloadsConfig, error) {
|
1346 | 1430 | l := v.([]interface{})
|
1347 | 1431 | if len(l) == 0 {
|
|
0 commit comments