2016-09-02 09:43:03 +02:00
---
layout: "aws"
page_title: "AWS: aws_ssm_association"
sidebar_current: "docs-aws-resource-ssm-association"
description: |-
Assosciates an SSM Document to an instance.
---
2017-05-09 16:48:57 +02:00
# aws_ssm_association
2016-09-02 09:43:03 +02:00
Assosciates an SSM Document to an instance.
## Example Usage
2017-04-17 12:17:54 +02:00
```hcl
2016-09-02 09:43:03 +02:00
resource "aws_security_group" "tf_test_foo" {
2017-02-18 23:48:50 +01:00
name = "tf_test_foo"
2016-09-02 09:43:03 +02:00
description = "foo"
2017-02-18 23:48:50 +01:00
2016-09-02 09:43:03 +02:00
ingress {
2017-02-18 23:48:50 +01:00
protocol = "icmp"
from_port = -1
to_port = -1
2016-09-02 09:43:03 +02:00
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "foo" {
# eu-west-1
2017-02-18 23:48:50 +01:00
ami = "ami-f77ac884"
2016-09-02 09:43:03 +02:00
availability_zone = "eu-west-1a"
2017-02-18 23:48:50 +01:00
instance_type = "t2.small"
security_groups = ["${aws_security_group.tf_test_foo.name}"]
2016-09-02 09:43:03 +02:00
}
resource "aws_ssm_document" "foo_document" {
2017-02-18 23:48:50 +01:00
name = "test_document_association-%s"
2016-09-02 09:43:03 +02:00
content = < < DOC
{
"schemaVersion": "1.2",
"description": "Check ip configuration of a Linux instance.",
"parameters": {
},
"runtimeConfig": {
"aws:runShellScript": {
"properties": [
{
"id": "0.aws:runShellScript",
"runCommand": ["ifconfig"]
}
]
}
}
}
DOC
}
resource "aws_ssm_association" "foo" {
2017-02-18 23:48:50 +01:00
name = "test_document_association-%s"
2016-09-02 09:43:03 +02:00
instance_id = "${aws_instance.foo.id}"
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the SSM document to apply.
2017-05-09 16:48:57 +02:00
* `instance_id` - (Optional) The instance id to apply an SSM document to.
2016-09-02 09:43:03 +02:00
* `parameters` - (Optional) Additional parameters to pass to the SSM document.
2017-05-09 16:48:57 +02:00
* `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. Only 1 target is currently supported by AWS.
2016-09-02 09:43:03 +02:00
## Attributes Reference
The following attributes are exported:
* `name` - The name of the SSM document to apply.
* `instance_ids` - The instance id that the SSM document was applied to.
* `parameters` - Additional parameters passed to the SSM document.