alicloud_ram_policy
Provides a RAM Policy resource.
-> NOTE: When you want to destroy this resource forcefully(means remove all the relationships associated with it automatically and then destroy it) without set force
with true
at beginning, you need add force = true
to configuration file and run terraform plan
, then you can delete resource forcefully.
-> NOTE: Each policy can own at most 5 versions and the oldest version will be removed after its version achieves 5.
-> NOTE: If the policy has multiple versions, all non-default versions will be deleted first when deleting policy.
-> NOTE: Available since v1.0.0+.
Example Usage
# Create a new RAM Policy.
resource "random_integer" "default" {
min = 10000
max = 99999
}
resource "alicloud_ram_policy" "policy" {
policy_name = "tf-example-${random_integer.default.result}"
policy_document = <<EOF
{
"Statement": [
{
"Action": [
"oss:ListObjects",
"oss:GetObject"
],
"Effect": "Allow",
"Resource": [
"acs:oss:*:*:mybucket",
"acs:oss:*:*:mybucket/*"
]
}
],
"Version": "1"
}
EOF
description = "this is a policy test"
}
Argument Reference
The following arguments are supported:
name
- (Deprecated since 1.114.0, Required, ForceNew) It has been deprecated since provider version 1.114.0 andpolicy_name
instead.policy_name
- (Required, ForceNew, Optional, Available since 1.114.0+) Name of the RAM policy. This name can have a string of 1 to 128 characters, must contain only alphanumeric characters or hyphen "-", and must not begin with a hyphen.statement
- (Deprecated since 1.49.0, Optional, Type: list, Conflicts withpolicy_document
,document
) (It has been deprecated since version 1.49.0, and use field 'document' to replace.) Statements of the RAM policy document. It is required when thedocument
is not specified. Seestatement
below.version
- (Deprecated since 1.49.0, Optional, Conflicts withpolicy_document
,document
) (It has been deprecated since version 1.49.0, and use field 'document' to replace.) Version of the RAM policy document. Valid value is1
. Default value is1
.document
- (Deprecated since 1.114.0, Optional, Conflicts withpolicy_document
,statement
andversion
) It has been deprecated since provider version 1.114.0 andpolicy_document
instead.policy_document
- (Optional, Conflicts withdocument
,statement
andversion
, Available since 1.114.0+) Document of the RAM policy. It is required when thestatement
is not specified.description
- (Optional, ForceNew) Description of the RAM policy. This name can have a string of 1 to 1024 characters.rotate_strategy
- (Optional, Available since 1.114.0+) The rotation strategy of the policy. You can use this parameter to delete an early policy version. Valid Values:None
,DeleteOldestNonDefaultVersionWhenLimitExceeded
. Default toNone
.force
- (Optional) This parameter is used for resource destroy. Default value isfalse
.
statement
The statement support the following:
resource
- (Deprecated since 1.49.0, Required, Type: list) (It has been deprecated since version 1.49.0, and use field 'document' to replace.) List of specific objects which will be authorized. The format of each item in this list isacs:${service}:${region}:${account_id}:${relative_id}
, such asacs:ecs:*:*:instance/inst-002
andacs:oss:*:1234567890000:mybucket
. The${service}
can beecs
,oss
,ots
and so on, the${region}
is the region info which can use*
replace when it is not supplied, the${account_id}
refers to someone's Alicloud account id or you can use*
to replace, the${relative_id}
is the resource description section which related to the${service}
.action
- (Deprecated since 1.49.0, Required, Type: list) (It has been deprecated since version 1.49.0, and use field 'document' to replace.) List of operations for theresource
. The format of each item in this list is${service}:${action_name}
, such asoss:ListBuckets
andecs:Describe*
. The${service}
can beecs
,oss
,ots
and so on, the${action_name}
refers to the name of an api interface which related to the${service}
.effect
- (Deprecated since 1.49.0, Required) (It has been deprecated since version 1.49.0, and use field 'document' to replace.) This parameter indicates whether or not theaction
is allowed. Valid values areAllow
andDeny
.
Attributes Reference
The following attributes are exported:
id
- The policy ID.type
- The policy type.attachment_count
- The policy attachment count.default_version
- The default version of policy.version_id
- The ID of default version policy.
Import
RAM policy can be imported using the id or name, e.g.
$ terraform import alicloud_ram_policy.example my-policy