我尝试创建具有相同功能的多个S3 buckt。但我无法创建多个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 :(得分: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
然而,
您必须单独声明每个资源;但是,如果您有多个相同类型的资源,则可以通过用逗号分隔它们来声明它们。
本文的措辞确实意味着有一条避免重复的捷径,但我从未见过这样一个有效的例子。