2015-04-23 16:24:45 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_iam_policy"
|
|
|
|
sidebar_current: "docs-aws-resource-iam-policy"
|
|
|
|
description: |-
|
|
|
|
Provides an IAM policy.
|
|
|
|
---
|
|
|
|
|
|
|
|
# aws\_iam\_policy
|
|
|
|
|
|
|
|
Provides an IAM policy.
|
|
|
|
|
2017-04-17 12:17:54 +02:00
|
|
|
```hcl
|
2015-04-23 16:24:45 +02:00
|
|
|
resource "aws_iam_policy" "policy" {
|
2017-02-18 23:48:50 +01:00
|
|
|
name = "test_policy"
|
|
|
|
path = "/"
|
|
|
|
description = "My test policy"
|
|
|
|
|
|
|
|
policy = <<EOF
|
2015-04-23 16:24:45 +02:00
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Action": [
|
|
|
|
"ec2:Describe*"
|
|
|
|
],
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Resource": "*"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `description` - (Optional) Description of the IAM policy.
|
2017-03-17 17:48:42 +01:00
|
|
|
* `name` - (Optional, Forces new resource) The name of the policy. If omitted, Terraform will assign a random, unique name.
|
2016-11-17 13:03:03 +01:00
|
|
|
* `name_prefix` - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with `name`.
|
2015-04-23 16:24:45 +02:00
|
|
|
* `path` - (Optional, default "/") Path in which to create the policy.
|
2016-11-17 13:03:03 +01:00
|
|
|
See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) for more information.
|
2015-04-23 16:24:45 +02:00
|
|
|
* `policy` - (Required) The policy document. This is a JSON formatted string.
|
2016-10-07 20:25:12 +02:00
|
|
|
The heredoc syntax, `file` function, or the [`aws_iam_policy_document` data
|
|
|
|
source](/docs/providers/aws/d/iam_policy_document.html)
|
|
|
|
are all helpful here.
|
2015-04-23 16:24:45 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The policy's ID.
|
|
|
|
* `arn` - The ARN assigned by AWS to this policy.
|
|
|
|
* `description` - The description of the policy.
|
|
|
|
* `name` - The name of the policy.
|
|
|
|
* `path` - The path of the policy in IAM.
|
|
|
|
* `policy` - The policy document.
|
2016-12-22 13:41:43 +01:00
|
|
|
|
|
|
|
## Import
|
|
|
|
|
|
|
|
IAM Policies can be imported using the `arn`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import aws_iam_policy.administrator arn:aws:iam::123456789012:policy/UsersManageOwnCredentials
|
2017-03-17 17:48:42 +01:00
|
|
|
```
|