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

相关问题