[英]How to get S3 bucket name from S3 ARN using cloudformation
我正在使用表達式,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
:
:
謝謝@berenbums 看一看——我自己也意識到這很有效。 還有一個問題掩蓋了這個問題。
所以畢竟,表達式,Select [5: ,Split [':', !Ref ResourceARN]]
可以用來將 ResourceARN 轉換為對應的 S3 存儲桶名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.