diff --git a/aws/resource_aws_ssm_association.go b/aws/resource_aws_ssm_association.go index e44363cd27e..e376c715f7d 100644 --- a/aws/resource_aws_ssm_association.go +++ b/aws/resource_aws_ssm_association.go @@ -75,7 +75,7 @@ func resourceAwsSsmAssociation() *schema.Resource { Optional: true, ForceNew: true, Computed: true, - MaxItems: 1, + MaxItems: 5, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "key": { diff --git a/aws/resource_aws_ssm_association_test.go b/aws/resource_aws_ssm_association_test.go index 791cc92b88d..4186e29e456 100644 --- a/aws/resource_aws_ssm_association_test.go +++ b/aws/resource_aws_ssm_association_test.go @@ -40,6 +40,35 @@ func TestAccAWSSSMAssociation_withTargets(t *testing.T) { Config: testAccAWSSSMAssociationBasicConfigWithTargets(name), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSSMAssociationExists("aws_ssm_association.foo"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.0.key", "tag:Name"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.0.values.0", "acceptanceTest"), + ), + }, + }, + }) +} + +func TestAccAWSSSMAssociation_withMultipleTargets(t *testing.T) { + name := acctest.RandString(10) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSSMAssociationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSSMAssociationBasicConfigWithMultipleTargets(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSSMAssociationExists("aws_ssm_association.foo"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.0.key", "tag:Name"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.0.values.0", "acceptanceTest"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.1.key", "tag:Environment"), + resource.TestCheckResourceAttr( + "aws_ssm_association.foo", "targets.1.values.0", "acceptanceTest"), ), }, }, @@ -365,6 +394,45 @@ resource "aws_ssm_association" "foo" { }`, rName) } +func testAccAWSSSMAssociationBasicConfigWithMultipleTargets(rName string) string { + return fmt.Sprintf(` +resource "aws_ssm_document" "foo_document" { + name = "test_document_association-%s", + document_type = "Command" + content = <