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

r/ssm_maintenance_window: Fix ssm maintenance window #2818

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
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