AWS CloudFormation 资源可以自己调用 !GetAtt 吗?
Can AWS CloudFormation resources call !GetAtt on themselves?
我正在尝试使用 CloudFormation 为 S3 存储桶设置清单配置。我想获取一个子文件夹中的每日数据清单,并将清单写入同一存储桶中的不同子文件夹。我定义了桶如下:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
# ...other properties...
InventoryConfigurations:
- Id: runs
Enabled: true
Destination:
BucketAccountId: !Ref AWS::AccountId
BucketArn: !GetAtt S3Bucket.Arn
Format: CSV
Prefix: inventory/runs/
IncludedObjectVersions: Current
OptionalFields: [ETag, Size, BucketKeyStatus]
Prefix: runs/
ScheduleFrequency: Daily
不幸的是,!GetAtt S3Bucket.Arn
行似乎失败了,导致出现类似“错误:无法为堆栈创建变更集:,例如:Waiter ChangeSetCreateComplete 失败:Waiter 遇到终端故障状态:对于我们匹配预期路径的表达式“状态”:“失败”状态:失败。原因:资源之间的循环依赖”。如果我使用存储桶的实际 ARN 代替 !GetAtt S3Bucket.Arn
(它已经存在于以前版本的堆栈中),那么部署会成功,所以我知道存储桶可以将 Inventories 写入自己。
所以我想我的问题是,有没有办法让 Cfn 资源自己调用 !GetAtt
,这样我就不必在 InventoryConfigurations
中硬编码存储桶 ARN?提前致谢!
Can AWS CloudFormation resources call !GetAtt on themselves?
很遗憾,没有,因为 !GetAtt
用于引用堆栈中的 other 资源,如您所经历的(其他已创建的具体资源) ).
但是,在您的情况下,考虑到您知道存储桶名称,您可以直接 construct the bucket ARN yourself。
格式:
arn:aws:s3:::bucket_name
例如如果名字是test
,你可以使用arn:aws:s3:::test
Destination:
BucketAccountId: !Ref AWS::AccountId
BucketArn: 'arn:aws:s3:::test'
我正在尝试使用 CloudFormation 为 S3 存储桶设置清单配置。我想获取一个子文件夹中的每日数据清单,并将清单写入同一存储桶中的不同子文件夹。我定义了桶如下:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
# ...other properties...
InventoryConfigurations:
- Id: runs
Enabled: true
Destination:
BucketAccountId: !Ref AWS::AccountId
BucketArn: !GetAtt S3Bucket.Arn
Format: CSV
Prefix: inventory/runs/
IncludedObjectVersions: Current
OptionalFields: [ETag, Size, BucketKeyStatus]
Prefix: runs/
ScheduleFrequency: Daily
不幸的是,!GetAtt S3Bucket.Arn
行似乎失败了,导致出现类似“错误:无法为堆栈创建变更集:,例如:Waiter ChangeSetCreateComplete 失败:Waiter 遇到终端故障状态:对于我们匹配预期路径的表达式“状态”:“失败”状态:失败。原因:资源之间的循环依赖”。如果我使用存储桶的实际 ARN 代替 !GetAtt S3Bucket.Arn
(它已经存在于以前版本的堆栈中),那么部署会成功,所以我知道存储桶可以将 Inventories 写入自己。
所以我想我的问题是,有没有办法让 Cfn 资源自己调用 !GetAtt
,这样我就不必在 InventoryConfigurations
中硬编码存储桶 ARN?提前致谢!
Can AWS CloudFormation resources call !GetAtt on themselves?
很遗憾,没有,因为 !GetAtt
用于引用堆栈中的 other 资源,如您所经历的(其他已创建的具体资源) ).
但是,在您的情况下,考虑到您知道存储桶名称,您可以直接 construct the bucket ARN yourself。
格式:
arn:aws:s3:::bucket_name
例如如果名字是test
,你可以使用arn:aws:s3:::test
Destination:
BucketAccountId: !Ref AWS::AccountId
BucketArn: 'arn:aws:s3:::test'