Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::APIG::Policy

Última atualização: Jun 27, 2026

Cria uma política para o Cloud-native API Gateway (APIG).

Sintaxe

{
  "Type": "ALIYUN::APIG::Policy",
  "Properties": {
    "AttachResourceIds": List,
    "AttachResourceType": String,
    "EnvironmentId": String,
    "GatewayId": String,
    "PolicyConfig": String,
    "PolicyClassName": String,
    "PolicyName": String
  }
}

Propriedades

Propriedade

Tipo

Obrigatória

Editável

Descrição

Restrição

AttachResourceIds

List

Sim

Não

IDs dos recursos para anexar a política.

Especifique até 10 IDs de recursos.

AttachResourceType

String

Sim

Não

Tipo de recurso compatível com a política.

Valores válidos:

  • HttpApi: API HTTP

  • Operation: operação da API HTTP

  • GatewayRoute: rota do gateway

  • GatewayService: serviço do gateway

  • GatewayServicePort: porta do serviço do gateway

  • Domain: domínio do gateway

  • Gateway: gateway

EnvironmentId

String

Sim

Não

Ambiente dos recursos para anexar a política.

Nenhuma.

GatewayId

String

Sim

Não

Gateway dos recursos para anexar a política.

Nenhuma.

PolicyConfig

String

Sim

Sim

Configuração da política.

Nenhuma.

PolicyClassName

String

Sim

Não

Alias da classe da política.

Valores válidos:

  • RateLimit

  • ConcurrencyLimit

  • CircuitBreaker

  • HttpRewrite

  • HeaderModify

  • Cors

  • FlowCopy

  • Timeout

  • Retry

  • IpAccessControl

  • DirectResponse

  • Redirect

  • Fallback

  • ServiceTls

  • ServiceLb

  • ServicePortTls

  • Waf

  • JWTAuth

  • OIDCAuth

  • ExternalZAuth

PolicyName

String

Não

Sim

Nome da política.

Nenhuma.

Valores de retorno

Fn::GetAtt

  • PolicyConfig: configuração da política.

  • PolicyClassId: ID da classe da política.

  • PolicyClassName: nome da classe da política.

  • PolicyName: nome da política.

  • PolicyId: ID da política.

Exemplos

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  GatewayId:
    Type: String
    Description:
      en: The ID of the Gateway.
    Required: true
    AssociationProperty: ALIYUN::APIG::Gateway::GatewayId
Resources:
  ExtensionResource:
    Type: ALIYUN::APIG::Policy
    Properties:
      AttachResourceIds:
        - op-xxxxx
      PolicyConfig: '{"strategy":0,"minRequestAmount":10,"statDurationSec":20,"triggerRatio":80,"recoveryTimeoutSec":10,"enable":true,"maxAllowedMs":1000,"behaviorType":0,"responseStatusCode":429,"bodyEncoding":0,"responseContentBody":"Circuit Breaker"}'
      AttachResourceType: Operation
      EnvironmentId: env-xxx
      PolicyClassName: CircuitBreaker
      GatewayId:
        Ref: GatewayId
Outputs:
  PolicyConfig:
    Description: Policy Configuration.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - PolicyConfig
  PolicyClassId:
    Description: The ID of policy class.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - PolicyClassId
  PolicyClassName:
    Description: The name of policy class.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - PolicyClassName
  PolicyName:
    Description: The name of the policy.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - PolicyName
  PolicyId:
    Description: The ID of the policy.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - PolicyId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "GatewayId": {
      "Type": "String",
      "Description": {
        "en": "The ID of the Gateway."
      },
      "Required": true,
      "AssociationProperty": "ALIYUN::APIG::Gateway::GatewayId"
    }
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::APIG::Policy",
      "Properties": {
        "AttachResourceIds": [
          "op-xxxxx"
        ],
        "PolicyConfig": "{\"strategy\":0,\"minRequestAmount\":10,\"statDurationSec\":20,\"triggerRatio\":80,\"recoveryTimeoutSec\":10,\"enable\":true,\"maxAllowedMs\":1000,\"behaviorType\":0,\"responseStatusCode\":429,\"bodyEncoding\":0,\"responseContentBody\":\"Circuit Breaker\"}",
        "AttachResourceType": "Operation",
        "EnvironmentId": "env-xxx",
        "PolicyClassName": "CircuitBreaker",
        "GatewayId": {
          "Ref": "GatewayId"
        }
      }
    }
  },
  "Outputs": {
    "PolicyConfig": {
      "Description": "Policy Configuration.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PolicyConfig"
        ]
      }
    },
    "PolicyClassId": {
      "Description": "The ID of policy class.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PolicyClassId"
        ]
      }
    },
    "PolicyClassName": {
      "Description": "The name of policy class.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PolicyClassName"
        ]
      }
    },
    "PolicyName": {
      "Description": "The name of the policy.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PolicyName"
        ]
      }
    },
    "PolicyId": {
      "Description": "The ID of the policy.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PolicyId"
        ]
      }
    }
  }
}