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