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