ALIYUN::APIG::Policy

ALIYUN::APIG::Policy类型用于创建策略。

语法

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

属性

属性名称

类型

必须

允许更新

描述

约束

AttachResourceIds

List

挂载资源 id 列表。

最多支持配置10组资源。

AttachResourceType

String

策略支持挂载点类型。

取值:

  • HttpApi:HttpApi。

  • Operation:HttpApi 的 Operation。

  • GatewayRoute:网关路由。

  • GatewayService:网关服务。

  • GatewayServicePort:网关服务端口。

  • Domain:网关域名。

  • Gateway:网关。

EnvironmentId

String

挂载资源所属环境。

GatewayId

String

挂载资源所属网关。

PolicyConfig

String

策略配置。

PolicyClassName

String

策略类别名。

取值:

  • RateLimit

  • ConcurrencyLimit

  • CircuitBreaker

  • HttpRewrite

  • HeaderModify

  • Cors

  • FlowCopy

  • Timeout

  • Retry

  • IpAccessControl

  • DirectResponse

  • Redirect

  • Fallback

  • ServiceTls

  • ServiceLb

  • ServicePortTls

  • Waf

  • JWTAuth

  • OIDCAuth

  • ExternalZAuth

PolicyName

String

策略名称。

返回值

Fn::GetAtt

  • PolicyConfig:策略配置。

  • PolicyClassId:策略类ID。

  • PolicyClassName:策略类名称。

  • PolicyName:策略名称。

  • PolicyId:策略ID。

示例

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"
        ]
      }
    }
  }
}