github.com/hobbeswalsh/terraform@v0.3.7-0.20150619183303-ad17cf55a0fa/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 policy = <<EOF 20 { 21 "Version": "2008-10-17", 22 "Statement": [ 23 { 24 "Action": "sts:AssumeRole", 25 "Principal": {"AWS": "*"}, 26 "Effect": "Allow", 27 "Sid": "" 28 } 29 ] 30 } 31 EOF 32 } 33 34 resource "aws_iam_role" "test_role" { 35 name = "test_role" 36 assume_role_policy = <<EOF 37 { 38 "Version": "2012-10-17", 39 "Statement": [ 40 { 41 "Action": "sts:AssumeRole", 42 "Principal": { 43 "Service": "ec2.amazonaws.com" 44 }, 45 "Effect": "Allow", 46 "Sid": "" 47 } 48 ] 49 } 50 EOF 51 } 52 ``` 53 54 ## Argument Reference 55 56 The following arguments are supported: 57 58 * `name` - (Required) The name of the role policy. 59 * `policy` - (Required) The policy document. This is a JSON formatted string. 60 The heredoc syntax or `file` function is helpful here. 61 * `role` - (Required) The IAM role to attach to the policy. 62 63 ## Attributes Reference 64 65 * `id` - The role policy ID. 66 * `name` - The name of the policy. 67 * `policy` - The policy document attached to the role. 68 * `role` - The role to which this policy applies.