You need to enable JavaScript to run this app.
导航

CreateSecurityGroup

最近更新时间2024.03.22 08:30:20

首次发布时间2021.07.29 14:11:53

调用 CreateSecurityGroup 接口,创建一个安全组。

调用说明

  • 单账号单地域默认最多可创建的安全组数量(含默认安全组)为300个。若默认配额无法满足需求,请前往 配额中心 提升相应配额。
  • 创建VPC时,系统自动为其默认创建一个名称为Default的安全组,即默认安全组。

调试

请求参数

参数名称
类型
是否必选
示例值
描述
ActionStringCreateSecurityGroup系统规定参数。取值:CreateSecurityGroup。
VersionString2020-04-01API版本信息,取值为:2020-04-01。

VpcId

String

vpc-bp1opxu1zkhn00gzv****

安全组所属VPC的ID。
您可以调用 DescribeVpcs 接口,查询VPC的ID。

SecurityGroupName

String

testSecurityGroupName

安全组的名称。

  • 长度限制为1 ~ 128个字符。
  • 需要以字母、中文或数字开头,可包含点号(.)、下划线(_)和短横线(-)。
  • 不填默认是安全组的ID。

Description

String

testDescription

安全组的描述信息。

  • 长度限制为0~ 255个字符。
  • 需要以字母、中文或数字开头。可包含英文逗号(,)、点号(.)、下划线(_)、空格( )、等号(=)、短横线(-)、中文逗号(,)、中文句号(。)。
  • 不填默认空字符串。
ProjectNameStringdefault安全组所属项目的名称。不填默认加入default项目。

Tags.N.Key

String

Tags.1.Key=key1&Tags.2.Key=key2

用户标签的标签键。

  • 参数 - N:表示标签键的序号,取值范围:1~50。
  • 多个标签键之间用&分隔。
  • 不能以 volc:sys:开头,包括任意大小写形式。
  • 长度取值范围为1~128字符,允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 若标签键开头或结尾存在空格,系统会自动为其去除。

说明

同一资源的标签键不允许重复。

Tags.N.Value

String

Tags.1.Value=value1&Tags.2.Value=value2

用户标签的标签值。

  • 参数 - N:表示标签值的序号,取值范围:1~50。
  • 多个标签值之间用&分隔。
  • 长度取值范围为0~256字符,不填默认为空。
  • 允许输入各国语言文字、数字、空格( )、下划线(_)、点号(.)、半角冒号(:)、斜杠(/)、等号(=)、加号(+)、中划线(-)和@(@)。
  • 大小写敏感。
  • 若标签值开头或结尾存在空格,系统会自动为其去除。

说明

若传入该参数,则必须先传入Tags.N.Key

ClientToken

String

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

客户端Token,用于保证请求幂等性。

  • 由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。
  • 仅支持ASCII字符,且不能超过64个字符。
  • 若不传入ClientToken,则此次API调用不进行幂等校验。

返回数据

参数名称
类型
示例值
描述
RequestIdString2021062415303301022514515207C4****请求ID。
SecurityGroupIdStringsg-bp1fg655nh68xyz9****新创建安全组的ID。

请求示例

GET /?Action=CreateSecurityGroup&Version=2020-04-01&VpcId=vpc-bp1ou1zkhn00gzv****&SecurityGroupName=SG_1 HTTP/1.1
Host: open.volcengineapi.com
Service: vpc
Region: cn-beijing

返回示例

{
    "ResponseMetadata": {
        "RequestId": "2021062415303301022514515207C4****",
        "Action": "CreateSecurityGroup",
        "Version": "2020-04-01",
        "Service": "vpc",
        "Region": "cn-beijing"
    },
   "Result": {
        "RequestId": "2021062415303301022514515207C4****",
        "SecurityGroupId": "sg-bp1fg655nh68xyz9****"
    }
}

错误码

此处仅展示当前API的错误码,更多错误码请参见公共错误码

HttpCode
错误码
错误信息
描述
400IdempotentParameterMismatchArguments on this idempotent request are inconsistent with arguments used in previous request(s).此幂等请求的参数与前一个请求中使用的参数不一致。
400InvalidDescription.MalformedThe specified description is malformed. Ensure the maximum length of description is 255.指定的描述格式不合法。描述长度不能超过255个字符。
400InvalidDescription.MalformedThe specified description is malformed.指定的描述格式不合法。请修复描述格式后重试。
400InvalidName.MalformedThe specified name is malformed. Ensure the maximum length of name is 128.指定的名称格式不合法。名称长度不能超过128个字符。
400InvalidName.MalformedThe specified name is malformed.指定的名称格式不合法。请修复名称格式后重试。
400InvalidParameter.ClientTokenMalformedThe specified parameter ClientToken is malformed.指定的参数ClientToken格式不合法,长度不能超过64个ASCII字符。
400InvalidTag.DisorderThe specified index order of tag is malformed.指定标签的索引顺序参数格式不合法。
400InvalidTagKey.MalformedThe specified parameter tag key is invalid.标签键不合法。
400InvalidTagValue.MalformedThe specified parameter tag value is invalid.标签值不合法。
400LimitExceeded.TagsYou've reached the limit on the number of tags that you can operate at one time.已达到单次可操作标签数量的上限。
400QuotaExceeded.SecurityGroupSecurity group number exceeded quota.已达到可创建安全组的数量上限。
404InvalidProject.NotFoundThe specified Project does not exist.指定的项目不存在。
404InvalidVpc.NotFoundThe specified VPC does not exist.指定的VPC不存在。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.幂等请求处理中。