簡體   English   中英

AWS CLI cloudformation 驗證模板成功,但在創建堆棧期間出錯

[英]AWS CLI cloudformation validate-template success but getting error during create-stack

再會。 我在“條件”部分進行了更改,其中

  1. 我有 Con1 作為第一個條件
  2. 然后 Con2 作為使用 Con1 的第二個

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 擴展截圖

Visual Studio Code 擴展可以在創作模板時內聯顯示這些錯誤

可悲的是, Fn::IfConditions不受支持 來自文檔

目前,AWS CloudFormation 在模板的資源部分和輸出部分的元數據屬性、更新策略屬性和屬性值中支持Fn::If 內在 function。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM