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/aws_ssm_maintenance_window_target: Change MaxItems of targets #2361

Merged
merged 4 commits into from
Nov 21, 2017
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
2 changes: 1 addition & 1 deletion aws/resource_aws_ssm_maintenance_window_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func resourceAwsSsmMaintenanceWindowTarget() *schema.Resource {
Type: schema.TypeList,
Required: true,
ForceNew: true,
MaxItems: 1,
MaxItems: 5,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {
Expand Down
6 changes: 6 additions & 0 deletions aws/resource_aws_ssm_maintenance_window_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func TestAccAWSSSMMaintenanceWindowTarget_basic(t *testing.T) {
Config: testAccAWSSSMMaintenanceWindowTargetBasicConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMMaintenanceWindowTargetExists("aws_ssm_maintenance_window_target.target"),
resource.TestCheckResourceAttr("aws_ssm_maintenance_window_target.target", "targets.0.key", "tag:Name"),
resource.TestCheckResourceAttr("aws_ssm_maintenance_window_target.target", "targets.1.key", "tag:Name2"),
),
},
},
Expand Down Expand Up @@ -117,6 +119,10 @@ resource "aws_ssm_maintenance_window_target" "target" {
key = "tag:Name"
values = ["acceptance_test"]
}
targets {
key = "tag:Name2"
values = ["acceptance_test", "acceptance_test2"]
}
}
`, rName)
}
14 changes: 7 additions & 7 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ func sliceContainsMap(l []interface{}, m map[string]interface{}) (int, bool) {
}

func expandAwsSsmTargets(d *schema.ResourceData) []*ssm.Target {
var targets []*ssm.Target
targets := make([]*ssm.Target, 0)

targetConfig := d.Get("targets").([]interface{})

Expand All @@ -2685,13 +2685,13 @@ func flattenAwsSsmTargets(targets []*ssm.Target) []map[string]interface{} {
}

result := make([]map[string]interface{}, 0, len(targets))
target := targets[0]
for _, target := range targets {
t := make(map[string]interface{}, 1)
t["key"] = *target.Key
t["values"] = flattenStringList(target.Values)

t := make(map[string]interface{})
t["key"] = *target.Key
t["values"] = flattenStringList(target.Values)

result = append(result, t)
result = append(result, t)
}

return result
}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/ssm_maintenance_window_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ The following arguments are supported:

The following attributes are exported:

* `id` - The ID of the maintenance window target.
* `id` - The ID of the maintenance window target.