From d9a8a32376e9fcea3b85ed1525b98fb56c667ae4 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 17 Jan 2019 14:13:02 -0500 Subject: [PATCH 1/2] r/aws_ssm_maintenance_window_task: Fix name/desc validation --- aws/resource_aws_ssm_maintenance_window_task.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_ssm_maintenance_window_task.go b/aws/resource_aws_ssm_maintenance_window_task.go index 414f7099fcb..39aad047b7a 100644 --- a/aws/resource_aws_ssm_maintenance_window_task.go +++ b/aws/resource_aws_ssm_maintenance_window_task.go @@ -86,7 +86,7 @@ func resourceAwsSsmMaintenanceWindowTask() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringLenBetween(3, 128), + ValidateFunc: validation.StringLenBetween(1, 128), }, "priority": { @@ -207,11 +207,17 @@ func resourceAwsSsmMaintenanceWindowTaskCreate(d *schema.ResourceData, meta inte TaskType: aws.String(d.Get("task_type").(string)), ServiceRoleArn: aws.String(d.Get("service_role_arn").(string)), TaskArn: aws.String(d.Get("task_arn").(string)), - Name: aws.String(d.Get("name").(string)), - Description: aws.String(d.Get("description").(string)), Targets: expandAwsSsmTargets(d.Get("targets").([]interface{})), } + if v, ok := d.GetOk("name"); ok { + params.Name = aws.String(v.(string)) + } + + if v, ok := d.GetOk("description"); ok { + params.Description = aws.String(v.(string)) + } + if v, ok := d.GetOk("priority"); ok { params.Priority = aws.Int64(int64(v.(int))) } From 8828117df0907ce17f0a2a612db28fae2b0d9a33 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 17 Jan 2019 14:21:35 -0500 Subject: [PATCH 2/2] r/aws_ssm_maintenance_window_task: Test with and without name, description --- aws/resource_aws_ssm_maintenance_window_task_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_ssm_maintenance_window_task_test.go b/aws/resource_aws_ssm_maintenance_window_task_test.go index 7d295e2ed0b..19bd2ccea99 100644 --- a/aws/resource_aws_ssm_maintenance_window_task_test.go +++ b/aws/resource_aws_ssm_maintenance_window_task_test.go @@ -25,8 +25,6 @@ func TestAccAWSSSMMaintenanceWindowTask_basic(t *testing.T) { Config: testAccAWSSSMMaintenanceWindowTaskBasicConfig(name), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSSMMaintenanceWindowTaskExists("aws_ssm_maintenance_window_task.target", &task), - resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "name", "TestMaintenanceWindowTask"), - resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "description", "This resource is for test purpose only"), ), }, }, @@ -51,6 +49,8 @@ func TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource(t *testing.T) { Config: testAccAWSSSMMaintenanceWindowTaskBasicConfigUpdated(name), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSSMMaintenanceWindowTaskExists("aws_ssm_maintenance_window_task.target", &after), + resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "name", "TestMaintenanceWindowTask"), + resource.TestCheckResourceAttr("aws_ssm_maintenance_window_task.target", "description", "This resource is for test purpose only"), testAccCheckAwsSsmWindowsTaskRecreated(t, &before, &after), ), }, @@ -143,8 +143,6 @@ resource "aws_ssm_maintenance_window_task" "target" { task_type = "RUN_COMMAND" task_arn = "AWS-RunShellScript" priority = 1 - name = "TestMaintenanceWindowTask" - description = "This resource is for test purpose only" service_role_arn = "${aws_iam_role.ssm_role.arn}" max_concurrency = "2" max_errors = "1"