All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::APIG::Policy

Last Updated:Dec 27, 2024

ALIYUN::APIG::Policy is used to create a policy.

Syntax

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

Properties

Property

Type

Required

Editable

Description

Constraint

AttachResourceIds

List

Yes

No

The IDs of the resources to be mounted.

You can specify up to 10 resource IDs.

AttachResourceType

String

Yes

No

The mount target type supported by the policy.

Valid values:

  • HttpApi: HTTP API

  • Operation: HTTP API operation

  • GatewayRoute: gateway route

  • GatewayService: gateway service

  • GatewayServicePort: gateway service port

  • Domain: gateway domain

  • Gateway: gateway

EnvironmentId

String

Yes

No

The environment to which the resources to be mounted belong.

None.

GatewayId

String

Yes

No

The gateway to which the resources to be mounted belong.

None.

PolicyConfig

String

Yes

Yes

The configuration of the policy.

None.

PolicyClassName

String

Yes

No

The alias of the policy class.

Valid values:

  • RateLimit

  • ConcurrencyLimit

  • CircuitBreaker

  • HttpRewrite

  • HeaderModify

  • Cors

  • FlowCopy

  • Timeout

  • Retry

  • IpAccessControl

  • DirectResponse

  • Redirect

  • Fallback

  • ServiceTls

  • ServiceLb

  • ServicePortTls

  • Waf

  • JWTAuth

  • OIDCAuth

  • ExternalZAuth

PolicyName

String

No

Yes

The name of the policy.

None.

Return values

Fn::GetAtt

  • PolicyConfig: the configuration of the policy.

  • PolicyClassId: the ID of the policy class.

  • PolicyClassName: the name of the policy class.

  • PolicyName: the name of the policy.

  • PolicyId: the ID of the policy.

Examples

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