github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/r/iam_role_policy_attachment.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_iam_role_policy_attachment"
     4  sidebar_current: "docs-aws-resource-iam-role-policy-attachment"
     5  description: |-
     6    Attaches a Managed IAM Policy to an IAM role
     7  ---
     8  
     9  # aws\_iam\_role\_policy\_attachment
    10  
    11  Attaches a Managed IAM Policy to an IAM role
    12  
    13  ```hcl
    14  resource "aws_iam_role" "role" {
    15      name = "test-role"
    16      assume_role_policy = <<EOF
    17      {
    18        "Version": "2012-10-17",
    19        "Statement": [
    20          {
    21            "Action": "sts:AssumeRole",
    22            "Principal": {
    23              "Service": "ec2.amazonaws.com"
    24            },
    25            "Effect": "Allow",
    26            "Sid": ""
    27          }
    28        ]
    29      }
    30  EOF
    31  }
    32  
    33  resource "aws_iam_policy" "policy" {
    34      name        = "test-policy"
    35      description = "A test policy"
    36      policy = <<EOF
    37  {
    38    "Version": "2012-10-17",
    39    "Statement": [
    40      {
    41        "Action": [
    42          "ec2:Describe*"
    43        ],
    44        "Effect": "Allow",
    45        "Resource": "*"
    46      }
    47    ]
    48  }
    49  EOF
    50  }
    51  
    52  resource "aws_iam_role_policy_attachment" "test-attach" {
    53      role       = "${aws_iam_role.role.name}"
    54      policy_arn = "${aws_iam_policy.policy.arn}"
    55  }
    56  ```
    57  
    58  ## Argument Reference
    59  
    60  The following arguments are supported:
    61  
    62  * `role`		(Required) - The role the policy should be applied to
    63  * `policy_arn`	(Required) - The ARN of the policy you want to apply