diff --git a/aws/resource_aws_ssm_maintenance_window_target.go b/aws/resource_aws_ssm_maintenance_window_target.go index c460ca6e3ae..20fbd3bc768 100644 --- a/aws/resource_aws_ssm_maintenance_window_target.go +++ b/aws/resource_aws_ssm_maintenance_window_target.go @@ -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": { diff --git a/aws/resource_aws_ssm_maintenance_window_target_test.go b/aws/resource_aws_ssm_maintenance_window_target_test.go index 8f02a0154bc..5ff21733b6e 100644 --- a/aws/resource_aws_ssm_maintenance_window_target_test.go +++ b/aws/resource_aws_ssm_maintenance_window_target_test.go @@ -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"), ), }, }, @@ -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) } diff --git a/aws/structure.go b/aws/structure.go index 9d49306a487..b6d1085b3f2 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -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{}) @@ -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 } diff --git a/website/docs/r/ssm_maintenance_window_target.html.markdown b/website/docs/r/ssm_maintenance_window_target.html.markdown index beff191eeeb..c05ed28d43f 100644 --- a/website/docs/r/ssm_maintenance_window_target.html.markdown +++ b/website/docs/r/ssm_maintenance_window_target.html.markdown @@ -43,4 +43,4 @@ The following arguments are supported: The following attributes are exported: -* `id` - The ID of the maintenance window target. \ No newline at end of file +* `id` - The ID of the maintenance window target.