This topic describes how to use Alibaba Cloud CLI version 3.0.25 or later to call API operations related to stack policies.

SetStackPolicy

You can call this operation to set a stack policy.

Parameter Type Required Example Description
--RegionId String Yes cn-hangzhou

The region ID of the stack. You can call the DescribeRegions operation to query the most recent region list.

--StackId String Yes 4a6c9851-3b0f-4f5f-b4ca-a14bf691****

The ID of the stack.

--StackPolicyBody String No {"Statement":[{"Effect":"Allow","Action":"Update:*","Principal":"*","Resource":"*"}]}

The structure that contains the stack policy body. The policy body must be 1 to 16,384 bytes in length.

You can specify either the StackPolicyBody parameter or the StackPolicyURL parameter. But you cannot specify both of them.

--StackPolicyURL String No oss://ros/stack-policy/demo

The URL for the file that contains the stack policy. The URL must point to a policy located in an HTTP or HTTPS web server or an Alibaba Cloud OSS bucket. Examples: oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou. If the region of the OSS bucket is not specified, the RegionId parameter value is used by default. The policy can be up to 16,384 bytes in length and the URL can be up to 1,350 bytes in length.

You can specify either the StackPolicyBody parameter or the StackPolicyURL parameter. But you cannot specify both of them.

Sample requests

aliyun ros SetStackPolicy  --StackId c18d62d8-51ce-4e8e-b8f6-e00be431**** --StackPolicyURL "oss://ros/stack-policy/demo"

Sample success responses

{
        "RequestId":"B258A0BE-D927-4381-B0F7-B35EF864B6E6F"
}

GetStackPolicy

You can call this operation to query information about a stack policy.

Parameter Type Required Example Description
--RegionId String Yes cn-hangzhou

The region ID of the stack. You can call the DescribeRegions operation to query the most recent region list.

--StackId String Yes 4a6c9851-3b0f-4f5f-b4ca-a14bf691****

The ID of the stack.

Sample requests

aliyun ros GetStackPolicy --RegionId cn-beijing  --StackId 939963e3-e84a-42a8-992b-c2474b75****

Sample success responses

{
        "StackPolicyBody":{
                "Statement":[
                        {
                                "Resource":"*",
                                "Principal":"*",
                                "Action":"Update:*",
                                "Effect":"Allow"
                        },
                        {
                                "Resource":"LogicalResourceId/WebServer",
                                "Principal":"*",
                                "Action":"Update:*",
                                "Effect":"Deny"
                        }
                ]
        },
        "RequestId":"5A81C4B1-CF6A-448B-9E2E-80B0F4CB4164"
}