Skip to content

Commit

Permalink
Merge pull request #7186 from YakDriver/bad_vladiator
Browse files Browse the repository at this point in the history
r/aws_ssm_maintenance_window_task: Fix name/desc validation
  • Loading branch information
bflad authored Feb 14, 2019
2 parents dccdfc8 + 8828117 commit 150a425
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 9 additions & 3 deletions aws/resource_aws_ssm_maintenance_window_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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)))
}
Expand Down
6 changes: 2 additions & 4 deletions aws/resource_aws_ssm_maintenance_window_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand All @@ -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),
),
},
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 150a425

Please sign in to comment.