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

resource/aws_ssm_association: Allow for multiple targets #2297

Merged
merged 4 commits into from
Jan 10, 2018

Conversation

tom-henderson
Copy link
Contributor

@tom-henderson tom-henderson commented Nov 15, 2017

AWS SSM Association supports a maximum of 5 targets - http://docs.aws.amazon.com/systems-manager/latest/APIReference/API_CreateAssociation.html

make testacc TEST=./aws TESTARGS='-run=TestAccAWSSSMAssociation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSSMAssociation -timeout 120m
=== RUN   TestAccAWSSSMAssociation_basic
--- PASS: TestAccAWSSSMAssociation_basic (141.40s)
=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (39.53s)
=== RUN   TestAccAWSSSMAssociation_withMultipleTargets
--- PASS: TestAccAWSSSMAssociation_withMultipleTargets (39.34s)
=== RUN   TestAccAWSSSMAssociation_withParameters
--- PASS: TestAccAWSSSMAssociation_withParameters (66.54s)
=== RUN   TestAccAWSSSMAssociation_withDocumentVersion
--- PASS: TestAccAWSSSMAssociation_withDocumentVersion (40.69s)
=== RUN   TestAccAWSSSMAssociation_withOutputLocation
--- PASS: TestAccAWSSSMAssociation_withOutputLocation (149.35s)
=== RUN   TestAccAWSSSMAssociation_withScheduleExpression
--- PASS: TestAccAWSSSMAssociation_withScheduleExpression (65.68s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	542.558s

@radeksimko radeksimko added enhancement Requests to existing resources that expand the functionality or scope. size/M Managed by automation to categorize the size of a PR. labels Nov 15, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tom-henderson

THanks for the work, looks really good :)

Just left a nitpick about adding checks on the state regarding targets.
Can you also resolve conflicts?

Good work! 👍

{
Config: testAccAWSSSMAssociationBasicConfigWithMultipleTargets(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMAssociationExists("aws_ssm_association.foo"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add steps checking that the targets are well set in the state?

@Ninir Ninir changed the title Allow multiple targets for aws_ssm_association resource/aws_ssm_association: Allow for multiple targets Nov 21, 2017
@tom-henderson
Copy link
Contributor Author

=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (39.40s)
=== RUN   TestAccAWSSSMAssociation_withMultipleTargets
--- PASS: TestAccAWSSSMAssociation_withMultipleTargets (40.35s)

Wasn't able to run all the tests this time - apparently we have too many S3 buckets.

@tom-henderson
Copy link
Contributor Author

@Ninir I think this should be good to go now 👍

@ziggythehamster
Copy link
Contributor

The AWS docs say that targets may have up to 50 items now:

http://docs.aws.amazon.com/systems-manager/latest/APIReference/API_Target.html

@tom-henderson
Copy link
Contributor Author

@ziggythehamster The docs for CreateAssociation I linked above still shows a maximum of 5. I tried setting the max to 50 and ran a test with 6 associations:

=== RUN   TestAccAWSSSMAssociation_withMultipleTargets
--- FAIL: TestAccAWSSSMAssociation_withMultipleTargets (24.37s)
        testing.go:503: Step 0 error: Error applying: 1 error(s) occurred:

                * aws_ssm_association.foo: 1 error(s) occurred:

                * aws_ssm_association.foo: [ERROR] Error creating SSM association: ValidationException: 1 validation error detected: Value '[com.amazonaws.services.ssm.Target@2bcbb0db, com.amazonaws.services.ssm.Target@879b5a53, com.amazonaws.services.ssm.Target@809e1af7, com.amazonaws.services.ssm.Target@24eaadb3, com.amazonaws.services.ssm.Target@747400f4, com.amazonaws.services.ssm.Target@2b8e1795, com.amazonaws.services.ssm.Target@a645e530]' at 'targets' failed to satisfy constraint: Member must have length less than or equal to 5
                        status code: 400, request id: fe24b46f-deb3-11e7-86c6-0b78a1784ae4
        testing.go:563: Error destroying resource! WARNING: Dangling resources
                may exist. The full state and error is shown below.

                Error: Check failed: Default error in SSM Association Test

                State: <no state>
FAIL
exit status 1
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       24.398s
make: *** [testacc] Error 1

@tom-henderson
Copy link
Contributor Author

@Ninir Is there anything else I can do to help get this merged?

@tom-henderson
Copy link
Contributor Author

tom-henderson commented Jan 8, 2018

Fixed conflicts.

make testacc TEST=./aws TESTARGS='-run=TestAccAWSSSMAssociation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSSMAssociation -timeout 120m
=== RUN   TestAccAWSSSMAssociation_basic
--- PASS: TestAccAWSSSMAssociation_basic (173.91s)
=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (41.15s)
=== RUN   TestAccAWSSSMAssociation_withMultipleTargets
--- PASS: TestAccAWSSSMAssociation_withMultipleTargets (39.00s)
=== RUN   TestAccAWSSSMAssociation_withParameters
--- PASS: TestAccAWSSSMAssociation_withParameters (66.72s)
=== RUN   TestAccAWSSSMAssociation_withAssociationName
--- PASS: TestAccAWSSSMAssociation_withAssociationName (65.99s)
=== RUN   TestAccAWSSSMAssociation_withDocumentVersion
--- PASS: TestAccAWSSSMAssociation_withDocumentVersion (41.65s)
=== RUN   TestAccAWSSSMAssociation_withOutputLocation
--- PASS: TestAccAWSSSMAssociation_withOutputLocation (152.24s)
=== RUN   TestAccAWSSSMAssociation_withScheduleExpression
--- PASS: TestAccAWSSSMAssociation_withScheduleExpression (65.41s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       646.102s

@tom-henderson
Copy link
Contributor Author

@radeksimko Is there anything I can do to help get this merged?

@hashicorp hashicorp deleted a comment from tom-henderson Jan 10, 2018
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tom-henderson

This is looking very good! thanks for the work & follow-up! 🚀 👍 ⭐️ 🎆

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSSSMAssociation_'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSSMAssociation_ -timeout 120m
=== RUN   TestAccAWSSSMAssociation_basic
--- PASS: TestAccAWSSSMAssociation_basic (157.78s)
=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (29.34s)
=== RUN   TestAccAWSSSMAssociation_withMultipleTargets
--- PASS: TestAccAWSSSMAssociation_withMultipleTargets (30.26s)
=== RUN   TestAccAWSSSMAssociation_withParameters
--- PASS: TestAccAWSSSMAssociation_withParameters (48.49s)
=== RUN   TestAccAWSSSMAssociation_withDocumentVersion
--- PASS: TestAccAWSSSMAssociation_withDocumentVersion (31.05s)
=== RUN   TestAccAWSSSMAssociation_withOutputLocation
--- PASS: TestAccAWSSSMAssociation_withOutputLocation (132.76s)
=== RUN   TestAccAWSSSMAssociation_withScheduleExpression
--- PASS: TestAccAWSSSMAssociation_withScheduleExpression (49.32s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws-clone/aws	479.046s

@Ninir Ninir merged commit 74c7ace into hashicorp:master Jan 10, 2018
@bflad
Copy link
Contributor

bflad commented Jan 12, 2018

This has been released in terraform-provider-aws version 1.7.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@bflad bflad added this to the v1.7.0 milestone Jan 12, 2018
@tom-henderson tom-henderson deleted the multiple-targets branch September 19, 2019 22:36
@ghost
Copy link

ghost commented Nov 1, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants