O tipo ALIYUN::ROS::Assert cria uma asserção que avalia condições com base em um tipo de operação especificado. Se o resultado da asserção for falso, o recurso poderá interromper a criação da pilha e retornar uma mensagem de erro personalizada.
Sintaxe
{
"Type": "ALIYUN::ROS::Assert",
"Properties": {
"Values": List,
"AbortCreation": Boolean,
"ErrorMessage": String,
"Operation": String
}
}
Propriedades
|
Propriedade |
Tipo |
Obrigatória |
Editável |
Descrição |
Restrição |
|
Values |
List |
Sim |
Não |
Asserções a serem avaliadas. |
As asserções são avaliadas em ordem. Especifique até três asserções. Nota
Especifique três asserções apenas quando Operation estiver definido como Equal ou NotEqual. Especifique apenas uma asserção quando Operation estiver definido como Not. |
|
AbortCreation |
Boolean |
Não |
Não |
Defina se a criação da pilha será interrompida em caso de falha na asserção. |
Valor padrão: True. |
|
ErrorMessage |
String |
Não |
Não |
Mensagem de erro retornada quando a asserção falha. |
Nenhuma. |
|
Operation |
String |
Não |
Não |
Tipo de operação usado para avaliar a asserção. |
Valores válidos:
|
Valores de retorno
Fn::GetAtt
Result: resultado da asserção.
FailureCause: motivo da falha na asserção.
Exemplos
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
Values:
Type: Json
Description:
en: |-
A list of values to assert. The items in the list are compared in order. The range of length is one to three.
- Three values are supported only if the operation is Equal or NotEqual.
- One value is supported only if the operation is Not.
Required: true
MinLength: 1
MaxLength: 3
Resources:
Assert:
Type: ALIYUN::ROS::Assert
Properties:
Values:
Ref: Values
Outputs:
Result:
Description: The result of the assert.
Value:
Fn::GetAtt:
- Assert
- Result
FailureCause:
Description: The reason the assertion failed
Value:
Fn::GetAtt:
- Assert
- FailureCause
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"Values": {
"Type": "Json",
"Description": {
"en": "A list of values to assert. The items in the list are compared in order. The range of length is one to three. \n- Three values are supported only if the operation is Equal or NotEqual.\n- One value is supported only if the operation is Not."
},
"Required": true,
"MinLength": 1,
"MaxLength": 3
}
},
"Resources": {
"Assert": {
"Type": "ALIYUN::ROS::Assert",
"Properties": {
"Values": {
"Ref": "Values"
}
}
}
},
"Outputs": {
"Result": {
"Description": "The result of the assert.",
"Value": {
"Fn::GetAtt": [
"Assert",
"Result"
]
}
},
"FailureCause": {
"Description": "The reason the assertion failed",
"Value": {
"Fn::GetAtt": [
"Assert",
"FailureCause"
]
}
}
}
}