Provides an IoT policy.
resource "aws_iot_policy" "pubsub" {
name = "PubSubToAnyTopic"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"iot:*",
]
Effect = "Allow"
Resource = "*"
},
]
})
}
This resource supports the following arguments:
name
- (Required) The name of the policy.policy
- (Required) The policy document. This is a JSON formatted string. Use the IoT Developer Guide for more information on IoT Policies. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.tags
- (Optional) Key-value mapping of resource tags. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.This resource exports the following attributes in addition to the arguments above:
arn
- The ARN assigned by AWS to this policy.name
- The name of this policy.default_version_id
- The default version of this policy.policy
- The policy document.tags_all
- Map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.update
- (Default 1m
)delete
- (Default 5m
)In Terraform v1.5.0 and later, use an import
block to import IoT policies using the name
. For example:
import {
to = aws_iot_policy.pubsub
id = "PubSubToAnyTopic"
}
Using terraform import
, import IoT policies using the name
. For example:
% terraform import aws_iot_policy.pubsub PubSubToAnyTopic