0

我正在嘗試創建多個具有相同propeties的S3桶。但我無法創建多個S3桶。創建與雲形成具有相同屬性的多個S3桶

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html 發現,如果你有相同類型的多個資源,你可以通過用逗號

分離一起宣佈他們,但我沒有找到任何例子,我不知道怎麼樣做到這一點。我試着調試,但沒有得到結果。 請建議。 下面是我的YAML文件:

AWSTemplateFormatVersion: '2010-09-09' 
Resources: 
    myS3Bucketlo: 
    Type: AWS::S3::Bucket 
    Properties: 
     AccessControl: AuthenticatedRead 
Outputs: 
    WebsiteURL: 
    Value: !GetAtt myS3Bucketlo.WebsiteURL 
    Description: URL for the website hosted on S3 

回答

0

在CloudFormation模板,每個資源必須另行申報。所以,即使你的水桶具有相同的性質,他們仍然必須單獨聲明:

AWSTemplateFormatVersion: '2010-09-09' 
Resources: 
    bucket1: 
    Type: AWS::S3::Bucket 
    Properties: 
     AccessControl: AuthenticatedRead 
    bucket2: 
    Type: AWS::S3::Bucket 
    Properties: 
     AccessControl: AuthenticatedRead 
    bucket3: 
    Type: AWS::S3::Bucket 
    Properties: 
     AccessControl: AuthenticatedRead 
Outputs: 
    WebsiteURL1: 
    Value: !GetAtt bucket1.WebsiteURL 
    Description: URL for the website 1 hosted on S3 
    WebsiteURL2: 
    Value: !GetAtt bucket2.WebsiteURL 
    Description: URL for the website 2 hosted on S3 
    WebsiteURL3: 
    Value: !GetAtt bucket3.WebsiteURL 
    Description: URL for the website 3 hosted on S3 

然而,

必須單獨申報每個資源;但是,如果您有多個相同類型的資源,則可以通過用逗號分隔它們來將它們聲明在一起。

本文的措詞確實意味着有一條避免重複的捷徑,但我從未見過這樣的工作示例。

+0

我沒有得到任何這樣的例子,我最終使用teraform,我發現很容易使用count聲明同一類型的多個資源。 – SmrutiRanjan

相關問題