簡體   English   中英

AWS cloudformation 錯誤:模板驗證錯誤:模板參數屬性無效

[英]AWS cloudformation error: Template validation error: Invalid template parameter property

我正在嘗試創建要使用的 cloudformation 模板,但我不斷收到上述錯誤。 這是我的模板中的片段:

"Mappings" : {
    "AWSInstanceType2Arch" : {
            "t1.micro" : { "Arch" : "64" },
            "m1.small" : { "Arch" : "64" },
            "m1.medium" : { "Arch" : "64" },
            "m1.large" : { "Arch" : "64" },
            "m1.xlarge" : { "Arch" : "64" },
            "m2.xlarge" : { "Arch" : "64" },
            "m2.2xlarge" : { "Arch" : "64" },
            "m2.4xlarge" : { "Arch" : "64" },
            "m3.xlarge" : { "Arch" : "64" },
            "m3.2xlarge" : { "Arch" : "64" },
            "c1.medium" : { "Arch" : "64" },
            "c1.xlarge" : { "Arch" : "64" },
            "cc1.4xlarge" : { "Arch" : "64HVM" },
            "cc2.8xlarge" : { "Arch" : "64HVM" },
            "cg1.4xlarge" : { "Arch" : "64HVM" }
        },
    "AWSRegionArch2AMI" : {
                "us-west-2": {"AMI": "ami-1b3b462b"}
         }
     },

  "Resources": {
    "Ec2Instance" : {
          "Type" : "AWS::EC2::Instance",
    "Properties": {
        "ImageId": { "Fn::FindInMap": [ "AWSRegionArch2AMI", { "Ref": "AWS::Region" },
        { "Fn::FindInMap": [ "AWSInstanceType2Arch", {"Ref": "InstanceType"}, "Arch" ] } ] },
            "InstanceType": {"Ref": "InstanceType"},
            "SecurityGroups": [ { "Ref": "SecurityGroups"} ],
            "KeyName": { "Ref": "KeyName" },
            "Tags": [ { "Key": "Name", "Value": { "Ref": "InstanceName" } } ] }
    },

我在底部發生了更多事情,例如要執行的 bash 腳本,除非我無法通過這個單一問題。 我錯過了什么?

我在尋找相同錯誤消息的解決方案時遇到了這個問題。

在我的情況下,我收到錯誤:

無效的模板參數屬性“屬性”

這是因為我在模板的“Parameters”:{} 部分而不是“Resources”:{} 部分中放置了一個資源定義。

錯誤消息是這樣的,因為資源有一個“屬性”部分,但“屬性”對參數無效。

當我嘗試將輸出添加到我的模板時,我遇到了相同的錯誤消息。

$ aws cloudformation validate-template --template-body "$(cat aws/vpc/production.template)"

A client error (ValidationError) occurred when calling the ValidateTemplate operation: Invalid template resource property 'InfrastructureIP'

我的問題是我在“資源”下而不是之后添加了輸出。

不正確

{
 "AWSTemplateFormatVersion" : "2010-09-09",

  "Parameters" : {
    #Some parameters
  },

  "Resources" : {
    #Whole lot of resources
    "Outputs" : {
      "InfrastructureIP" : {
        "Description": "The private IP of Infrastructure",  
        "Value" : { "Fn::GetAtt" : [ "Infrastructure", "PrivateIp" ] }
      }
    }
  }
}

正確的

{
 "AWSTemplateFormatVersion" : "2010-09-09",

  "Parameters" : {
    #Some parameters
  },

  "Resources" : {
    #Whole lot of resources
  },

  "Outputs" : {
    "InfrastructureIP" : {
      "Description": "The private IP of Infrastructure",  
      "Value" : { "Fn::GetAtt" : [ "Infrastructure", "PrivateIp" ] }
    }
  }
}

我有一個類似於security groups的變量名我通過執行securityGroups擺脫了這個錯誤

檢查您的 json 鍵以獲取正確的命名約定

是間距問題。 固定的。 模板可能很棘手。

就我而言,我將模板文件中的輸出稱為 [Output],而不是 [Outputs],從而導致了此問題。

我在尋找問題的解決方案時遇到了這個問題 -

錯誤是無效的模板屬性或屬性

就我而言,這是spacing問題。 所以在我的例子中,我們使用jinja來生成模板,而一個模板方法(生成output )沒有適當的縮進或空格。 在數小時后解決問題后終於修復了它。

檢查是否缺少任何空格或任何名稱錯誤的屬性(請記住,屬性區分大小寫)。 所以“屬性”是正確的,但“屬性”不是。 'KeyType' 是對的,但 'keyType' 不是。

因此,問題可能在於未遵循間距或命名約定

暫無
暫無

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

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