All Products
Search
Document Center

:ModifySecurityGroupPolicy

更新时间:Dec 01, 2023

Modifies the internal access control policy of a basic security group. The internal access control policies of advanced security groups cannot be modified.

Usage notes

Take note of the following items:

  • When InnerAccessPolicy is set to Accept for a security group, the instances in the security group can communicate with each other. The Accept internal access control policy takes precedence over user-created security group rules to keep instances in the security group accessible to each other.
  • When InnerAccessPolicy is set to Drop for a security group, the instances in the security group are isolated from each other. In this case, user-created security group rules take precedence over the Drop internal access control policy and can be used to allow access between the instances. For example, you can call the AuthorizeSecurityGroup operation to create an inbound security group rule that allows the instances in the security group to communicate with each other.
  • You can call the DescribeSecurityGroupAttribute operation to query the internal access control policy of a security group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action String Yes ModifySecurityGroupPolicy

The operation that you want to perform. Set the value to ModifySecurityGroupPolicy.

SecurityGroupId String Yes sg-bp67acfmxazb4ph****

The ID of the security group.

RegionId String Yes cn-hangzhou

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

InnerAccessPolicy String Yes Drop

The internal access control policy of the security group. Valid values:

  • Accept
  • Drop
Note The value of this parameter is case-insensitive.
ClientToken String No 123e4567-e89b-12d3-a456-426655440000

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 contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

Response parameters

Parameter

Type

Example

Description

RequestId String CEF72CEB-54B6-4AE8-B225-F876FF7BA984

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=ModifySecurityGroupPolicy
&RegionId=cn-hangzhou
&SecurityGroupId=sg-bp67acfmxazb4ph****
&InnerAccessPolicy=Drop
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifySecurityGroupPolicyResponse>
    <RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
</ModifySecurityGroupPolicyResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "CEF72CEB-54B6-4AE8-B225-F876FF7BA984"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidSecurityGroupId.Malformed The SecurityGroupId is invalid. Only letters, numbers and underscores are supported. Maximum length is 100 characters. Invalid SecurityGroupId value. The value can be up to 100 characters in length and can contain only letters, digits, and underscores (_).
403 InvalidOperation.ResourceManagedByCloudProduct %s You cannot modify security groups managed by cloud services.
404 InvalidSecurityGroupId.NotFound The specified SecurityGroupId does not exist. The specified security group is not found in this account. Check whether the security group ID is correct.

For a list of error codes, see Service error codes.