github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/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 ```hcl 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` - (Optional) The name of the role policy. If omitted, Terraform will 62 assign a random, unique name. 63 * `name_prefix` - (Optional) Creates a unique name beginning with the specified 64 prefix. Conflicts with `name`. 65 * `policy` - (Required) The policy document. This is a JSON formatted string. 66 The heredoc syntax or `file` function is helpful here. 67 * `role` - (Required) The IAM role to attach to the policy. 68 69 ## Attributes Reference 70 71 * `id` - The role policy ID. 72 * `name` - The name of the policy. 73 * `policy` - The policy document attached to the role. 74 * `role` - The role to which this policy applies.