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

provider/aws: Add support for targets to aws_ssm_association #14246

Merged
merged 2 commits into from
May 9, 2017

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented May 5, 2017

Fixes: #13975

% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSSMAssociation_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/05/05 20:32:43 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSSMAssociation_ -timeout 120m
=== RUN   TestAccAWSSSMAssociation_basic
--- PASS: TestAccAWSSSMAssociation_basic (139.13s)
=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (33.19s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	172.343s

Fixes: #13975

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSSMAssociation_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/05/05 20:32:43 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSSMAssociation_ -timeout 120m
=== RUN   TestAccAWSSSMAssociation_basic
--- PASS: TestAccAWSSSMAssociation_basic (139.13s)
=== RUN   TestAccAWSSSMAssociation_withTargets
--- PASS: TestAccAWSSSMAssociation_withTargets (33.19s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	172.343s
```
@liamjbennett
Copy link
Contributor

@stack72 Thanks

Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

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

LGTM, one minor doc nit

* `parameters` - (Optional) Additional parameters to pass to the SSM document.
* `targets` - (Optional) The targets (either instances or tags). Instances are specified using Key=instanceids,Values=instanceid1,instanceid2. Tags are specified using Key=tag name,Values=tag value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a note that only one item is allowed here?

@@ -2085,3 +2086,39 @@ func sliceContainsMap(l []interface{}, m map[string]interface{}) (int, bool) {

return -1, false
}

func expandAwsSsmTargets(d *schema.ResourceData) []*ssm.Target {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding these here


return resourceAwsSsmAssociationRead(d, meta)
}

func resourceAwsSsmAssociationRead(d *schema.ResourceData, meta interface{}) error {
ssmconn := meta.(*AWSClient).ssmconn

log.Printf("[DEBUG] Reading SSM Assosciation: %s", d.Id())
log.Printf("[DEBUG] Reading SSM Association: %s", d.Id())
Copy link
Contributor

Choose a reason for hiding this comment

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

@stack72 stack72 merged commit 9dd4e5b into master May 9, 2017
@stack72 stack72 deleted the f-aws-ssm-association-target-support-13975 branch May 9, 2017 14:49
@nicwise
Copy link

nicwise commented May 17, 2017

@stack72 I'm curious on this - how do you go about going from pre-0.9.5 SSM associations (name+instanceid) to the new ones, short of hand editing the state or deleting them and reassociating

@stack72
Copy link
Contributor Author

stack72 commented May 18, 2017

Hi @nicwise

The old ones will still work - if you need to move to the new ones, just change the resource code locally and terraform will destroy and recreate the association

Paul

@nicwise
Copy link

nicwise commented May 18, 2017

Odd @stack72 . We didn't change the terraform code at all, just did an apply with 0.9.5, and it was complaining about not having association_id

Ended up using the command line to find the id's and inject them into the state, then push it back.

@stack72
Copy link
Contributor Author

stack72 commented May 19, 2017

Hi @nicwise

Please can you drop some configuration here so that I can try to reproduce?

Thanks

Paul

@nicwise
Copy link

nicwise commented May 24, 2017

Sorry for the delay. Here's the TF:

resource "aws_ssm_association" "statsd-node_configuration_ssm" {
  name        = "${aws_ssm_document.statsd-node_configuration_ssm.name}"
  instance_id = "${aws_instance.statsd_node.id}"
}

and the state

"aws_ssm_association.statsd-node_configuration_ssm": {
                    "type": "aws_ssm_association",
                    "depends_on": [
                        "aws_instance.statsd_node",
                        "aws_ssm_document.statsd-node_configuration_ssm"
                    ],
                    "primary": {
                        "id": "test_statsd-node_configuration_ssm",
                        "attributes": {
                            "association_id": "fd6xxxxx-xxxx-xxxx-xxxx-xxxxxxxafb5", <--- wasn't here when it was erroring
                            "id": "test_statsd-node_configuration_ssm",
                            "instance_id": "i-040cxxxxxxx96f",
                            "name": "test_statsd-node_configuration_ssm",
                            "parameters.%": "0",
                            "targets.#": "1",
                            "targets.0.key": "InstanceIds",
                            "targets.0.values.#": "1",
                            "targets.0.values.0": "i-04xxxxxxx96f"
                        },
                        "meta": {},
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": ""
                },

this was failing, saying it didn't have an association_id - that line above wasn't in the state at that point.

Sso we looked up the ID using the API, edited the state to include the line above, and 👍

We only had, I think, 9 of these, so it wasn't huge to do by hand.

@ghost
Copy link

ghost commented Apr 12, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Targeting resource tags for aws_ssm_association
4 participants