Skip to content

Commit

Permalink
fix cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushi-ishibashi committed Jan 6, 2018
1 parent c3b13ed commit 10895f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions aws/resource_aws_ssm_maintenance_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func resourceAwsSsmMaintenanceWindowCreate(d *schema.ResourceData, meta interfac
}

d.SetId(*resp.WindowId)
return resourceAwsSsmMaintenanceWindowRead(d, meta)
return resourceAwsSsmMaintenanceWindowUpdate(d, meta)
}

func resourceAwsSsmMaintenanceWindowUpdate(d *schema.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -98,9 +98,7 @@ func resourceAwsSsmMaintenanceWindowUpdate(d *schema.ResourceData, meta interfac
params.AllowUnassociatedTargets = aws.Bool(d.Get("allow_unassociated_targets").(bool))
}

if d.HasChange("enabled") {
params.Enabled = aws.Bool(d.Get("enabled").(bool))
}
params.Enabled = aws.Bool(d.Get("enabled").(bool))

_, err := ssmconn.UpdateMaintenanceWindow(params)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions aws/resource_aws_ssm_maintenance_window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func TestAccAWSSSMMaintenanceWindow_basic(t *testing.T) {
"aws_ssm_maintenance_window.foo", "cutoff", "1"),
resource.TestCheckResourceAttr(
"aws_ssm_maintenance_window.foo", "name", fmt.Sprintf("maintenance-window-%s", name)),
resource.TestCheckResourceAttr(
"aws_ssm_maintenance_window.foo", "enabled", "false"),
),
},
{
Expand All @@ -44,6 +46,8 @@ func TestAccAWSSSMMaintenanceWindow_basic(t *testing.T) {
"aws_ssm_maintenance_window.foo", "cutoff", "8"),
resource.TestCheckResourceAttr(
"aws_ssm_maintenance_window.foo", "name", fmt.Sprintf("updated-maintenance-window-%s", name)),
resource.TestCheckResourceAttr(
"aws_ssm_maintenance_window.foo", "enabled", "true"),
),
},
},
Expand Down Expand Up @@ -123,6 +127,7 @@ resource "aws_ssm_maintenance_window" "foo" {
schedule = "cron(0 16 ? * TUE *)"
duration = 3
cutoff = 1
enabled = false
}
`, rName)
Expand All @@ -135,6 +140,7 @@ resource "aws_ssm_maintenance_window" "foo" {
schedule = "cron(0 16 ? * WED *)"
duration = 10
cutoff = 8
enabled = true
}
`, rName)
Expand Down

0 comments on commit 10895f9

Please sign in to comment.