2

我通過cloudformation創建了一個EFSVPC中,此VPC包含幾個EC2 instances如何知道由Cloudformation創建多少個Mount目標

我需要爲每個子網創建和安裝目標。

這個雲信息模板可以在不同的AWS accounts中執行。 如何知道如何創建資源?

我可以在帳戶1 VPC的3 subnets,帳戶2另一個VPC 2 subnets ...

如何使模板通用,這樣它根據每個帳戶的環境裏去?

"FileSystem" : { 
     "Type" : "AWS::EFS::FileSystem", 
     "Properties" : { 
     "FileSystemTags" : [ 
      { 
      "Key" : "Name", 
      "Value" : "FileSystem" 
      } 
     ] 
     } 
    }, 

    "MountTarget1": { 
     "Type": "AWS::EFS::MountTarget", 
     "Properties": { 
     "FileSystemId": { "Ref": "FileSystem" }, 
     "SubnetId": { "Ref": "Subnet1" }, 
     "SecurityGroups": [ { "Ref": "MountTargetSecurityGroup" } ] 
     } 
    }, 

    "MountTarget2": { 
     "Type": "AWS::EFS::MountTarget", 
     "Properties": { 
     "FileSystemId": { "Ref": "FileSystem" }, 
     "SubnetId": { "Ref": "Subnet2" }, 
     "SecurityGroups": [ { "Ref": "MountTargetSecurityGroup" } ] 
     } 
    }, 

回答

0

據我瞭解,你要能夠重複使用跨帳戶此相同的模板和創建基於由帳戶所需子網的數量MountTargets適當數量。

根據子網數量(ACL,路由表等)的不同,會有很多變量和條件適用。你也許可以用大量的條件和參數來完成它,但是模板會變得相當混亂。雖然這不是一個優雅的解決方案。

更好的方法是使用對流層創建您的模板。這裏有一個EFS的例子來幫助你入門。 https://github.com/cloudtools/troposphere/blob/master/examples/EFS.py

相關問題