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

Support schedulers argument in aws_mwaa_environment #21941

Merged
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/21941.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_mwaa_environment: Add `schedulers` argument
```
14 changes: 14 additions & 0 deletions internal/service/mwaa/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ func ResourceEnvironment() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"schedulers": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"service_role_arn": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -292,6 +297,10 @@ func resourceEnvironmentCreate(d *schema.ResourceData, meta interface{}) error {
input.RequirementsS3Path = aws.String(v.(string))
}

if v, ok := d.GetOk("schedulers"); ok {
input.Schedulers = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("webserver_access_mode"); ok {
input.WebserverAccessMode = aws.String(v.(string))
}
Expand Down Expand Up @@ -366,6 +375,7 @@ func resourceEnvironmentRead(d *schema.ResourceData, meta interface{}) error {
d.Set("plugins_s3_path", environment.PluginsS3Path)
d.Set("requirements_s3_object_version", environment.RequirementsS3ObjectVersion)
d.Set("requirements_s3_path", environment.RequirementsS3Path)
d.Set("schedulers", environment.Schedulers)
d.Set("service_role_arn", environment.ServiceRoleArn)
d.Set("source_bucket_arn", environment.SourceBucketArn)
d.Set("status", environment.Status)
Expand Down Expand Up @@ -452,6 +462,10 @@ func resourceEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error {
input.RequirementsS3Path = aws.String(d.Get("requirements_s3_path").(string))
}

if d.HasChange("schedulers") {
input.Schedulers = aws.Int64(int64(d.Get("schedulers").(int)))
}

if d.HasChange("source_bucket_arn") {
input.SourceBucketArn = aws.String(d.Get("source_bucket_arn").(string))
}
Expand Down
3 changes: 3 additions & 0 deletions internal/service/mwaa/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestAccMWAAEnvironment_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "network_configuration.#", "1"),
resource.TestCheckResourceAttr(resourceName, "network_configuration.0.security_group_ids.#", "1"),
resource.TestCheckResourceAttr(resourceName, "network_configuration.0.subnet_ids.#", "2"),
resource.TestCheckResourceAttr(resourceName, "schedulers", "2"),
resource.TestCheckResourceAttrSet(resourceName, "service_role_arn"),
acctest.CheckResourceAttrGlobalARNNoAccount(resourceName, "source_bucket_arn", "s3", rName),
resource.TestCheckResourceAttrSet(resourceName, "status"),
Expand Down Expand Up @@ -287,6 +288,7 @@ func TestAccMWAAEnvironment_full(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "network_configuration.0.subnet_ids.#", "2"),
resource.TestCheckResourceAttr(resourceName, "plugins_s3_path", "plugins.zip"),
resource.TestCheckResourceAttr(resourceName, "requirements_s3_path", "requirements.txt"),
resource.TestCheckResourceAttr(resourceName, "schedulers", "1"),
resource.TestCheckResourceAttrSet(resourceName, "service_role_arn"),
acctest.CheckResourceAttrGlobalARNNoAccount(resourceName, "source_bucket_arn", "s3", rName),
resource.TestCheckResourceAttrSet(resourceName, "status"),
Expand Down Expand Up @@ -729,6 +731,7 @@ resource "aws_mwaa_environment" "test" {

plugins_s3_path = aws_s3_object.plugins.key
requirements_s3_path = aws_s3_object.requirements.key
schedulers = 1
source_bucket_arn = aws_s3_bucket.test.arn
webserver_access_mode = "PUBLIC_ONLY"
weekly_maintenance_window_start = "SAT:03:00"
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/mwaa_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ The following arguments are supported:
* `plugins_s3_path` - (Optional) The relative path to the plugins.zip file on your Amazon S3 storage bucket. For example, plugins.zip. If a relative path is provided in the request, then plugins_s3_object_version is required. For more information, see [Importing DAGs on Amazon MWAA](https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-dag-import.html).
* `requirements_s3_object_version` - (Optional) The requirements.txt file version you want to use.
* `requirements_s3_path` - (Optional) The relative path to the requirements.txt file on your Amazon S3 storage bucket. For example, requirements.txt. If a relative path is provided in the request, then requirements_s3_object_version is required. For more information, see [Importing DAGs on Amazon MWAA](https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-dag-import.html).
* `schedulers` - (Optional) The number of schedulers that you want to run in your environment. v2.0.2 and above accepts `2` - `5`, default `2`. v1.10.12 accepts `1`.
* `source_bucket_arn` - (Required) The Amazon Resource Name (ARN) of your Amazon S3 storage bucket. For example, arn:aws:s3:::airflow-mybucketname.
* `webserver_access_mode` - (Optional) Specifies whether the webserver should be accessible over the internet or via your specified VPC. Possible options: `PRIVATE_ONLY` (default) and `PUBLIC_ONLY`.
* `weekly_maintenance_window_start` - (Optional) Specifies the start date for the weekly maintenance window.
Expand Down