【发布时间】:2020-11-10 02:39:30
【问题描述】:
我正在使用表达式!Select [5, !Split [':', !Ref ResourceARN]] 将ResourceARN(一个堆栈的STRING 输入参数)转换为相应的S3 bucket name,以将其传递给子堆栈。
示例:来自arn:aws:s3:::tests3bucket-1a3o2v3wr375g 期望创建tests3bucket-1a3o2v3wr375g
相反,它评估为空字符串,因为我得到Parameters: [S3BucketName] must have values。
我怎样才能做到这一点?
这是主堆栈模板:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
ResourceARN:
Description: 'The AWS ARN associated with S3 resource, example arn:aws:s3:::tests3bucket-1a3o2v3wr375g'
ConstraintDescription: The ARN of the resource
Type: String
:
:
Resources:
ChildStack:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: !Sub >-
https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}/templates/child.template
Parameters:
S3BucketName: !Select [5, !Split [':', !Ref ResourceARN]] # Expecting to evaluate to tests3bucket-1a3o2v3wr375g
:
:
这是子模板:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
S3BucketName:
Description: 'The name of the S3 bucket'
Type: String
:
:
【问题讨论】:
-
代码看起来不错, !Select 表达式也是如此。当我将存储桶添加到主堆栈模板时,我可以使用正确命名的存储桶部署堆栈。您确定在部署堆栈时将资源 ARN 作为参数传递吗?
-
欣赏评论@berenbums ...确实没问题,问题出在其他地方。
标签: amazon-web-services amazon-s3 expression amazon-cloudformation