github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/website/source/docs/providers/aws/r/iam_policy_attachment.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_iam_policy_attachment"
     4  sidebar_current: "docs-aws-resource-iam-policy-attachment"
     5  description: |-
     6    Attaches a Managed IAM Policy to user(s), role(s), and/or group(s)
     7  ---
     8  
     9  # aws\_iam\_policy\_attachment
    10  
    11  Attaches a Managed IAM Policy to user(s), role(s), and/or group(s)
    12  
    13  ~> **NOTE:** The aws_iam_policy_attachment resource is only meant to be used once for each managed policy. All of the users/roles/groups that a single policy is being attached to should be declared by a single aws_iam_policy_attachment resource.
    14  
    15  ```
    16  resource "aws_iam_user" "user" {
    17      name = "test-user"
    18  }
    19  resource "aws_iam_role" "role" {
    20      name = "test-role"
    21  }
    22  resource "aws_iam_group" "group" {
    23      name = "test-group"
    24  }
    25  
    26  resource "aws_iam_policy" "policy" {
    27      name = "test-policy"
    28      description = "A test policy"
    29      policy = 	#omitted
    30  }
    31  
    32  resource "aws_iam_policy_attachment" "test-attach" {
    33      name = "test-attachment"
    34      users = ["${aws_iam_user.user.name}"]
    35      roles = ["${aws_iam_role.role.name}"]
    36      groups = ["${aws_iam_group.group.name}"]
    37      policy_arn = "${aws_iam_policy.policy.arn}"
    38  }
    39  ```
    40  
    41  ## Argument Reference
    42  
    43  The following arguments are supported:
    44  
    45  * `name` 		(Required) - The name of the policy.
    46  * `users`		(Optional) - The user(s) the policy should be applied to
    47  * `roles`		(Optional) - The role(s) the policy should be applied to
    48  * `groups`		(Optional) - The group(s) the policy should be applied to
    49  * `policy_arn`	(Required) - The ARN of the policy you want to apply
    50  
    51  ## Attributes Reference
    52  
    53  The following attributes are exported:
    54  
    55  * `id` - The policy's ID.
    56  * `name` - The name of the policy.