Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add input argument to enable webserver auto scalling #37632

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/37632.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_mwaa_environment: Add `max_webservers` and `min_webservers` attributes
```
30 changes: 30 additions & 0 deletions internal/service/mwaa/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,24 @@ func ResourceEnvironment() *schema.Resource {
},
},
},
"max_webservers": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(2, 5),
},
"max_workers": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntAtLeast(1),
},
"min_webservers": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(2, 5),
},
"min_workers": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -357,6 +369,14 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta
input.MinWorkers = aws.Int32(int32(v.(int)))
}

if v, ok := d.GetOk("max_webservers"); ok {
input.MaxWebservers = aws.Int32(int32(v.(int)))
}

if v, ok := d.GetOk("min_webservers"); ok {
input.MinWebservers = aws.Int32(int32(v.(int)))
}

if v, ok := d.GetOk("plugins_s3_object_version"); ok {
input.PluginsS3ObjectVersion = aws.String(v.(string))
}
Expand Down Expand Up @@ -451,6 +471,8 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i
}
d.Set("max_workers", environment.MaxWorkers)
d.Set("min_workers", environment.MinWorkers)
d.Set("max_webservers", environment.MaxWebservers)
d.Set("min_webservers", environment.MinWebservers)
d.Set(names.AttrName, environment.Name)
if err := d.Set(names.AttrNetworkConfiguration, flattenNetworkConfiguration(environment.NetworkConfiguration)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting network_configuration: %s", err)
Expand Down Expand Up @@ -522,6 +544,14 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
input.MinWorkers = aws.Int32(int32(d.Get("min_workers").(int)))
}

if d.HasChange("max_webservers") {
input.MaxWebservers = aws.Int32(int32(d.Get("max_webservers").(int)))
}

if d.HasChange("min_webservers") {
input.MinWebservers = aws.Int32(int32(d.Get("min_webservers").(int)))
}

if d.HasChange(names.AttrNetworkConfiguration) {
input.NetworkConfiguration = expandEnvironmentNetworkConfigurationUpdate(d.Get(names.AttrNetworkConfiguration).([]interface{}))
}
Expand Down
11 changes: 10 additions & 1 deletion internal/service/mwaa/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func TestAccMWAAEnvironment_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "logging_configuration.0.worker_logs.0.log_level", "INFO"),
resource.TestCheckResourceAttr(resourceName, "max_workers", acctest.Ct10),
resource.TestCheckResourceAttr(resourceName, "min_workers", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "max_webservers", acctest.Ct2),
resource.TestCheckResourceAttr(resourceName, "min_webservers", acctest.Ct2),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, "network_configuration.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "network_configuration.0.security_group_ids.#", acctest.Ct1),
Expand Down Expand Up @@ -291,6 +293,8 @@ func TestAccMWAAEnvironment_full(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "logging_configuration.0.worker_logs.0.log_level", "WARNING"),
resource.TestCheckResourceAttr(resourceName, "max_workers", "20"),
resource.TestCheckResourceAttr(resourceName, "min_workers", "15"),
resource.TestCheckResourceAttr(resourceName, "max_webservers", "5"),
resource.TestCheckResourceAttr(resourceName, "min_webservers", acctest.Ct4),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttr(resourceName, "network_configuration.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "network_configuration.0.security_group_ids.#", acctest.Ct1),
Expand Down Expand Up @@ -789,7 +793,11 @@ resource "aws_mwaa_environment" "test" {

max_workers = 20
min_workers = 15
name = %[1]q

max_webservers = 5
min_webservers = 4

name = %[1]q

network_configuration {
security_group_ids = [aws_security_group.test.id]
Expand Down Expand Up @@ -862,6 +870,7 @@ resource "aws_s3_object" "startup_script" {
content = "airflow db init"
}


`, rName))
}

Expand Down
Loading