帮你快速理解、总结文档立即下载

修改VPC边界访问控制规则

最近更新时间:2026-07-27 01:26:09

我的收藏

1. 接口描述

接口请求域名: cfw.tencentcloudapi.com 。

修改一条 VPC边界访问控制规则。

默认接口请求频率限制:20次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:ModifyVpcAcRule。
Version String 公共参数,本接口取值:2019-09-04。
Region String 公共参数,本接口不需要传递此参数。
Rules.N Array of VpcRuleItem 待修改的规则数组,必须恰好包含一条完整规则,不是局部更新。调用 DescribeCfwRules,传 RuleType=vpc、目标 RuleUuid、ExpandNames=false 获取原规则。字段转换:uuid→Uuid,sequence→OrderIndex,src_ip→SourceContent,src_type→SourceType,dst_content→DestContent,dst_type→DestType,dst_port→Port,detail→Description,edge_id→EdgeId,fwgroupid→FwGroupId,ip_version→IpVersion;action 的 0、1、2 分别转换为 log、drop、accept,enabled 的布尔值转换为字符串 true、false;protocol、param_template_id、dest_value_type 分别写入 Protocol、ParamTemplateId、DestValueType。src_type 和 dst_type 的 1、2、3、4/5、6、8、9、10、100 分别对应 net、url、domain、template、instance、tag、dnsparse、domainiptwoverify、group;仅当转换结果属于对应 SourceType 或 DestType 的有效取值时才能提交。省略的可写字段不会继承旧值,IpVersion=0 也必须传入。不修改生效范围时,将原规则的 edge_id 和 fwgroupid 原样写入 EdgeId 和 FwGroupId;主动更换时,EdgeId 通过 DescribeVpcAclEdgeRange 查询,FwGroupId 通过 DescribeFwGroupIdNames 查询。
CfwAiAgentOperationSource String

AI操作来源

枚举值:

  • console: 控制台来源值
  • wechat: 微信

示例值:console

3. 输出参数

参数名称 类型 描述
RuleUuids Array of Integer 修改后的规则 ID 列表,成功时包含请求规则的 Uuid。
示例值:[8888]
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 修改一条 IPv4 VPC 规则

将 Uuid 指定的 VPC 规则修改为拒绝。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyVpcAcRule
X-TC-Version: 2019-09-04

{
    "Rules": [
        {
            "Uuid": 246810,
            "SourceType": "net",
            "SourceContent": "192.0.2.0/24",
            "DestType": "net",
            "DestContent": "198.51.100.0/24",
            "Protocol": "TCP",
            "Port": "443",
            "ParamTemplateId": "",
            "RuleAction": "drop",
            "Description": "Documented service traffic policy",
            "OrderIndex": 12,
            "Enable": "true",
            "EdgeId": "ALL",
            "FwGroupId": "ALL",
            "IpVersion": 0
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuids": [
            246810
        ],
        "RequestId": "123e4567-e89b-42d3-a456-426614174000"
    }
}

示例2 修改一条 IPv6 VPC 规则

先查询并确认规则的完整 IPv6 配置,再按完整字段重建规则;示例保持 IPv6 地址版本并修改为观察动作。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyVpcAcRule
X-TC-Version: 2019-09-04

{
    "Rules": [
        {
            "Uuid": 246812,
            "SourceType": "net",
            "SourceContent": "2001:db8:1::/64",
            "DestType": "net",
            "DestContent": "2001:db8:2::/64",
            "Protocol": "UDP",
            "Port": "53",
            "ParamTemplateId": "",
            "RuleAction": "log",
            "Description": "观察 IPv6 VPC DNS 流量",
            "OrderIndex": 13,
            "Enable": "true",
            "EdgeId": "ALL",
            "FwGroupId": "ALL",
            "IpVersion": 1
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuids": [
            246812
        ],
        "RequestId": "123e4567-e89b-42d3-a456-426614174001"
    }
}

示例3 将 VPC 规则修改为协议端口模板规则

使用协议端口模板修改 Uuid 指定的 VPC 规则。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyVpcAcRule
X-TC-Version: 2019-09-04

{
    "Rules": [
        {
            "Uuid": 246814,
            "SourceType": "net",
            "SourceContent": "192.0.2.130",
            "DestType": "net",
            "DestContent": "198.51.100.130",
            "Protocol": "ANY",
            "Port": "-1/-1",
            "ParamTemplateId": "pp-maatbnad",
            "RuleAction": "log",
            "Description": "VPC 协议端口模板观察规则",
            "OrderIndex": 2,
            "Enable": "false",
            "EdgeId": "cfws-b29ca53311",
            "FwGroupId": "ALL",
            "IpVersion": 0
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuids": [
            246814
        ],
        "RequestId": "123e4567-e89b-42d3-a456-426614174002"
    }
}

示例4 将 VPC 规则修改为实例访问严格匹配域名

用户要求指定实例仅在域名和解析 IP 同时匹配时访问外部服务。先调用 DescribeCfwRules 查询目标规则的完整字段,调用 DescribeCfwAssets 获取来源 assets[].instance_id,再将目的类型改为 domainiptwoverify。

输入示例

POST / HTTP/1.1
Host: cfw.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyVpcAcRule
X-TC-Version: 2019-09-04

{
    "Rules": [
        {
            "Uuid": 246815,
            "SourceType": "instance",
            "SourceContent": "ins-xxxxxxxx",
            "DestType": "domainiptwoverify",
            "DestContent": "example.org",
            "Protocol": "TCP",
            "Port": "443",
            "ParamTemplateId": "",
            "RuleAction": "log",
            "Description": "观察实例访问严格匹配域名",
            "OrderIndex": 11,
            "Enable": "false",
            "EdgeId": "ALL",
            "FwGroupId": "ALL",
            "IpVersion": 0
        }
    ]
}

输出示例

{
    "Response": {
        "RuleUuids": [
            246815
        ],
        "RequestId": "123e4567-e89b-42d3-a456-426614174003"
    }
}

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
FailedOperation 操作失败。
InvalidParameter 参数错误。
LimitExceeded 超过配额限制。
UnauthorizedOperation 未授权操作。
UnsupportedOperation 操作不支持。