[英]AWS CLI cloudformation validate-template success but getting error during create-stack
再會。 我在“條件”部分進行了更改,其中
在aws cloudformation validate-template
中,結果是成功。 但是當我開始通過aws cloudformation create-stack
使用 create-stack 時,我得到了錯誤:
An error occurred (ValidationError) when calling the CreateStack operation: Template error: Fn::If cannot be preprocessed
這是我在條件部分所做的更改。
"Conditions": { "Con1": { "Fn::Not": [{ "Fn::Equals": [ {"Ref": "Environment"}, "abc" ] }] }, "Con2": { "Fn::Not": [{ "Fn::Equals": [ { "Fn::If": [ "Con1", { "Fn::FindInMap": [ "iamRoles", {"Ref": "HostnameAppId"}, "abc"] }, { "Fn::FindInMap": [ "iamRoles", {"Ref": "HostnameAppId"}, "xyz"] } ] }, ""] }] } },
雖然aws cloudformation validate-template
驗證不多,但CloudFormation Linter會在部署之前捕獲這些問題:
E8003 Fn::Equals element must be a supported function (Ref, Fn::FindInMap, Fn::Sub, Fn::Join, Fn::Select, Fn::Split)
Visual Studio Code 擴展可以在創作模板時內聯顯示這些錯誤
可悲的是, Fn::If
在Conditions
中不受支持。 來自文檔:
目前,AWS CloudFormation 在模板的資源部分和輸出部分的元數據屬性、更新策略屬性和屬性值中支持Fn::If 內在 function。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.