github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/r/iam_role_policy.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_iam_role_policy" 4 sidebar_current: "docs-aws-resource-iam-role-policy" 5 description: |- 6 Provides an IAM role policy. 7 --- 8 9 # aws\_iam\_role\_policy 10 11 Provides an IAM role policy. 12 13 ## Example Usage 14 15 ``` 16 resource "aws_iam_role_policy" "test_policy" { 17 name = "test_policy" 18 role = "${aws_iam_role.test_role.id}" 19 20 policy = <<EOF 21 { 22 "Version": "2012-10-17", 23 "Statement": [ 24 { 25 "Action": [ 26 "ec2:Describe*" 27 ], 28 "Effect": "Allow", 29 "Resource": "*" 30 } 31 ] 32 } 33 EOF 34 } 35 36 resource "aws_iam_role" "test_role" { 37 name = "test_role" 38 39 assume_role_policy = <<EOF 40 { 41 "Version": "2012-10-17", 42 "Statement": [ 43 { 44 "Action": "sts:AssumeRole", 45 "Principal": { 46 "Service": "ec2.amazonaws.com" 47 }, 48 "Effect": "Allow", 49 "Sid": "" 50 } 51 ] 52 } 53 EOF 54 } 55 ``` 56 57 ## Argument Reference 58 59 The following arguments are supported: 60 61 * `name` - (Required) The name of the role policy. 62 * `policy` - (Required) The policy document. This is a JSON formatted string. 63 The heredoc syntax or `file` function is helpful here. 64 * `role` - (Required) The IAM role to attach to the policy. 65 66 ## Attributes Reference 67 68 * `id` - The role policy ID. 69 * `name` - The name of the policy. 70 * `policy` - The policy document attached to the role. 71 * `role` - The role to which this policy applies.