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 | 是 | 否 | 策略支持挂载点类型。 | 取值:
|
EnvironmentId | String | 是 | 否 | 挂载资源所属环境。 | 无 |
GatewayId | String | 是 | 否 | 挂载资源所属网关。 | 无 |
PolicyConfig | String | 是 | 是 | 策略配置。 | 无 |
PolicyClassName | String | 是 | 否 | 策略类别名。 | 取值:
|
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"
]
}
}
}
}
文档内容是否对您有帮助?