I'm using the expression ,Select [5: ,Split [':', !Ref ResourceARN]]
to convert ResourceARN
, which is a STRING input parameter to a stack, to the corresponding S3 bucket name
, to pass it to a child stack.
Example: from arn:aws:s3:::tests3bucket-1a3o2v3wr375g
expecting to create tests3bucket-1a3o2v3wr375g
Instead it evaluates to empty string, as I'm getting Parameters: [S3BucketName] must have values
.
How can I make this work?
Here is the main stack template:
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
:
:
and here is the child template:
AWSTemplateFormatVersion: 2010-09-09
Parameters:
S3BucketName:
Description: 'The name of the S3 bucket'
Type: String
:
:
Thank you @berenbums for taking a look - just realized myself too that this works. There was another issue which masked the problem.
So after all, the expression ,Select [5: ,Split [':', !Ref ResourceARN]]
can be used to convert ResourceARN to the corresponding S3 bucket name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.