title: How to get S3 bucket name from S3 ARN using cloudformation
body: <p>I'm using the expression <code>!Select [5, !Split [':', !Ref ResourceARN]]</code> to convert <code>ResourceARN</code>, which is a STRING input parameter to a stack, to the corresponding <code>S3 bucket name</code>, to pass it to a child stack.</p>
  <p>Example: from <code>arn:aws:s3:::tests3bucket-1a3o2v3wr375g</code> expecting to create <code>tests3bucket-1a3o2v3wr375g</code></p>
  <p>Instead it evaluates to empty string, as I'm getting <code>Parameters: [S3BucketName] must have values</code>.</p>
  <p>How can I make this work?</p>
  <hr />
  <p>Here is the main stack template:</p>
  <pre><code>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 &gt;-
          https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}/templates/child.template
        Parameters:
          S3BucketName: !Select [5, !Split [':', !Ref ResourceARN]] # Expecting to evaluate to tests3bucket-1a3o2v3wr375g
  :
  :
  </code></pre>
  <p>and here is the child template:</p>
  <pre><code>AWSTemplateFormatVersion: 2010-09-09
  Parameters:
    S3BucketName:
      Description: 'The name of the S3 bucket'
      Type: String
  :
  :
  
  </code></pre>