All Products
Search
Document Center

Resource Orchestration Service:ListStackOperationRisks

Last Updated:Sep 12, 2024

Detects stack-related operation risks and returns missing permissions and the causes of the risks.

Operation description

The ListStackOperationRisks operation is suitable for the following scenarios:

  • You want to detect high risks that may arise in resources when you delete a stack that contains the resources, and query the cause of each risk in a resource.
  • When you create a stack, the creation may fail. In this case, you can call this operation to check which types of permissions that are required to create stacks are missing.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ros:ListStackOperationRisksget
  • stack
    acs:ros:{#regionId}:{#accountId}:stack/{#stackId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

cn-hangzhou
StackIdstringNo

The ID of the stack.

4a6c9851-3b0f-4f5f-b4ca-a14bf691****
OperationTypestringYes

The type of the operation of which you want to detect risks. Valid values:

  • DeleteStack: detects high risks that may arise in resources when you delete a stack.
  • CreateStack: detects the missing permissions when you fail to create a stack.
DeleteStack
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can be up to 64 characters in length, and can contain letters, digits, hyphens (-), and underscores (_). For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-42665544****
RamRoleNamestringNo

The name of the RAM role.

  • If you specify a RAM role, ROS creates stacks based on the permissions that are granted to the RAM role and uses the credentials of the RAM role to call the API operations of Alibaba Cloud services.
  • If you do not specify a RAM role, ROS creates stacks based on the permissions of your Alibaba Cloud account.

The name of the RAM role can be up to 64 bytes in length.

test-role
RetainAllResourcesbooleanNo

Specifies whether to retain all resources in the stack. Valid values:

  • true
  • false (default)
Note This parameter takes effect only if you set OperationType to DeleteStack.
false
RetainResourcesarrayNo

The list of resources to retain.

Note This parameter takes effect only if you set OperationType to DeleteStack.
stringNo

The resource that you want to retain.

instance
TemplateBodystringNo

The structure that contains the template body. The template body must be 1 to 524,288 bytes in length. If the length of the template body exceeds the upper limit, we recommend that you add parameters to the HTTP POST request body to prevent request failures caused by excessively long URLs.

Note You must and can specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
{"ROSTemplateFormatVersion":"2015-09-01"}
TemplateURLstringNo

The URL of the file that contains the template body. The URL must point to a template that is located on an HTTP or HTTPS web server or in an Object Storage Service (OSS) bucket, such as oss://ros/stack-policy/demo and oss://ros/stack-policy/demo?RegionId=cn-hangzhou. The template body can be up to 524,288 bytes in length. If you do not specify RegionId in the URL, the region ID of the stack is used.

Note You must specify one of TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
oss://ros-template/demo
TemplateIdstringNo

The ID of the template. This parameter applies to shared and private templates.

Note You must specify one of TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.
5ecd1e10-b0e9-4389-a565-e4c15efc****
TemplateVersionstringNo

The version of the template.

Note This parameter takes effect only if you specify TemplateId.
v1

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

72108E7A-E874-4A5E-B22C-A61E94AD12CD
RiskResourcesarray<object>

The resources that are at risk.

object
LogicalResourceIdstring

The logical ID of the resource. The logical ID is the resource name that is defined in the template.

MySG
PhysicalResourceIdstring

The physical ID of the resource. The physical ID is the actual ID of the resource.

sg-bp1dpioafqphedg9****
RequestIdstring

The ID of the request when the risk detection fails.

Note This parameter is not returned if the risk detection is successful.
DF4296CF-F45F-4845-A72B-BE617601DB25
ResourceTypestring

The type of the resource.

ALIYUN::ECS::SecurityGroup
Codestring

The error code that is returned when the risk detection fails.

Note This parameter is not returned if the risk detection is successful.
NoPermission
Messagestring

The error message that is returned when the risk detection fails.

Note This parameter is not returned if the risk detection is successful.
You are not authorized to complete this action.
RiskTypestring

The type of the risk. Valid values:

  • Referenced: The resource is referenced by other resources.
  • MaybeReferenced: The resource may be referenced by other resources.
  • AdditionalRiskCheckRequired: An additional risk detection is required for a nested stack.
  • OperationIgnored: The operation does not take effect for the resource.
Referenced
Reasonstring

The cause of the risk.

There are some ECS instances (i-bp18el96s4wq635e****) depending on the security group.
MissingPolicyActionsarray

The operations on which the permissions are not granted to the Alibaba Cloud account of the caller.

string

The operation on which the permissions are not granted to the Alibaba Cloud account of the caller.

["ecs:DescribeInstance", "ros:CreateStack"]

Examples

Sample success responses

JSONformat

{
  "RequestId": "72108E7A-E874-4A5E-B22C-A61E94AD12CD",
  "RiskResources": [
    {
      "LogicalResourceId": "MySG",
      "PhysicalResourceId": "sg-bp1dpioafqphedg9****",
      "RequestId": "DF4296CF-F45F-4845-A72B-BE617601DB25",
      "ResourceType": "ALIYUN::ECS::SecurityGroup",
      "Code": "NoPermission",
      "Message": "You are not authorized to complete this action.",
      "RiskType": "Referenced",
      "Reason": "There are some ECS instances (i-bp18el96s4wq635e****) depending on the security group."
    }
  ],
  "MissingPolicyActions": [
    "[\"ecs:DescribeInstance\", \"ros:CreateStack\"]"
  ]
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-01-12The internal configuration of the API is changed, but the call is not affectedView Change Details