2017-04-12 43 views
0

我在使用嵌套堆棧創建堆棧時遇到問題。我有一個主模板(列出的用於測試,並且僅引用一個嵌套堆棧)。我想弄清楚如何將主值傳遞給嵌套堆棧,還是有更好的方法來做到這一點?每次嘗試創建堆棧,我得到一個:AWS cloudformation將值傳遞給嵌套堆棧

Template format error: Unresolved resource dependencies [VpcCidrBlock] in the Resources block of the template. 

我的理解是指我把在主堆棧中的參數不獲取傳遞到嵌套堆棧。

主模板:

{ 
    "AWSTemplateFormatVersion" : "2010-09-09", 
    "Description" : "Master template", 
    "Parameters" : { 
     "availabilityZone" : { 
      "Default" : "us-east-1d", 
      "Description" : "Enter AvailabilityZone.", 
      "Type" : "String" 
     }, 
     "VpcCidrBlock" : { 
      "Default" : "10.0.0.0/16", 
      "Description" : "VPC CIDR Block.", 
      "Type" : "String" 
     } 
    }, 
    "Resources" : { 
     "VPCStack" : { 
      "Type" : "AWS::CloudFormation::Stack", 
      "Properties" : { 
       "TemplateURL" : "https://s3.amazonaws.com/dev.url.templates/templates/vpcStack.json", 
       "TimeoutInMinutes" : "5", 
       "Parameters" : { 
        "VpcCidrBlock" : { 
         "Ref" : "VpcCidrBlock" 
        } 
       } 
      } 
     } 
    } 
} 

VPC模板:

{ 
    "AWSTemplateFormatVersion" : "2010-09-09", 
    "Description" : "VPC template", 
    "Resources" : { 
     "VpcStack" : { 
      "Type" : "AWS::EC2::VPC", 
      "Properties" : { 
       "EnableDnsSupport" : "true", 
       "EnableDnsHostnames" : "true", 
       "CidrBlock" : { 
        "Ref" : "VpcCidrBlock" 
       }, 
       "Tags" : [ 
        { 
         "Key" : "Application", 
         "Value" : { 
          "Ref" : "AWS::StackName" 
         } 
        } 
       ] 
      } 
     } 
    } 
} 

謝謝!

回答

0

你的內部模板需要輸入參數:

"Parameters" : { 
    "VpcCidrBlock" : { 
     "Description" : "VPC CIDR Block.", 
     "Type" : "String" 
    } 
}, 

就像你的外在「包裝」模板。

相關問題