diff --git a/.changelog/37632.txt b/.changelog/37632.txt new file mode 100644 index 000000000000..9e6737cb6848 --- /dev/null +++ b/.changelog/37632.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_mwaa_environment: Add `max_webservers` and `min_webservers` attributes +``` \ No newline at end of file diff --git a/internal/service/mwaa/environment.go b/internal/service/mwaa/environment.go index 12d87e990b13..1c3681462832 100644 --- a/internal/service/mwaa/environment.go +++ b/internal/service/mwaa/environment.go @@ -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, @@ -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)) } @@ -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) @@ -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{})) } diff --git a/internal/service/mwaa/environment_test.go b/internal/service/mwaa/environment_test.go index 451d81af6394..e5f4fa561e44 100644 --- a/internal/service/mwaa/environment_test.go +++ b/internal/service/mwaa/environment_test.go @@ -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), @@ -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), @@ -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] @@ -862,6 +870,7 @@ resource "aws_s3_object" "startup_script" { content = "airflow db init" } + `, rName)) }