Skip to content

Commit e76d2d5

Browse files
committed
feat(mwaa): add worker_replacement_strategy variable
Add support for configuring the worker replacement strategy when updating MWAA environments. This allows users to choose between FORCED (immediate replacement) and GRACEFUL (wait up to 12 hours for tasks to complete) strategies. - Add worker_replacement_strategy variable to root module - Add worker_replacement_strategy to complete example - Default to null in root module to preserve existing behavior
1 parent 98d4a7c commit e76d2d5

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

examples/complete/fixtures.us-east-2.tfvars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ min_workers = 1
2222

2323
max_workers = 10
2424

25+
worker_replacement_strategy = "FORCED"
26+
2527
webserver_access_mode = "PRIVATE_ONLY"
2628

2729
dag_processing_logs_enabled = true

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module "mwaa" {
3232
environment_class = var.environment_class
3333
min_workers = var.min_workers
3434
max_workers = var.max_workers
35+
worker_replacement_strategy = var.worker_replacement_strategy
3536
webserver_access_mode = var.webserver_access_mode
3637
dag_processing_logs_enabled = var.dag_processing_logs_enabled
3738
dag_processing_logs_level = var.dag_processing_logs_level

examples/complete/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,15 @@ variable "min_workers" {
104104
description = "The minimum number of workers that you want to run in your environment."
105105
default = 1
106106
}
107+
108+
variable "worker_replacement_strategy" {
109+
type = string
110+
description = "The worker replacement strategy to use when updating the environment. Valid values: `FORCED`, `GRACEFUL`. `FORCED` means Apache Airflow workers will be stopped and replaced without waiting for tasks to complete before an update. `GRACEFUL` means Apache Airflow workers will be able to complete running tasks for up to 12 hours during an update before being stopped and replaced."
111+
default = "FORCED"
112+
113+
validation {
114+
condition = contains(["FORCED", "GRACEFUL"], var.worker_replacement_strategy)
115+
error_message = "Valid values are: `FORCED` or `GRACEFUL`."
116+
}
117+
}
118+

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ resource "aws_mwaa_environment" "default" {
223223
kms_key = var.kms_key
224224
max_workers = var.max_workers
225225
min_workers = var.min_workers
226+
worker_replacement_strategy = var.worker_replacement_strategy
226227
min_webservers = var.environment_class == "mw1.micro" ? 1 : var.min_webservers
227228
max_webservers = var.environment_class == "mw1.micro" ? 1 : var.max_webservers
228229
schedulers = var.schedulers

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ variable "min_workers" {
8181
default = 1
8282
}
8383

84+
variable "worker_replacement_strategy" {
85+
type = string
86+
description = "The worker replacement strategy to use when updating the environment. Valid values: `FORCED`, `GRACEFUL`. `FORCED` means Apache Airflow workers will be stopped and replaced without waiting for tasks to complete before an update. `GRACEFUL` means Apache Airflow workers will be able to complete running tasks for up to 12 hours during an update before being stopped and replaced."
87+
default = null
88+
89+
validation {
90+
condition = var.worker_replacement_strategy == null || contains(["FORCED", "GRACEFUL"], var.worker_replacement_strategy)
91+
error_message = "Valid values are: `FORCED`, `GRACEFUL`, or `null`."
92+
}
93+
}
94+
8495
variable "max_webservers" {
8596
type = number
8697
description = "The maximum number of web servers that you want to run in your environment."

0 commit comments

Comments
 (0)