title: Work around circular dependency in AWS CloudFormation
body: <p>The following AWS CloudFormation gives a circular dependency error. My understanding is that the dependencies flow like this: <code>rawUploads -&gt; generatePreview -&gt; previewPipeline -&gt; rawUploads</code>. Although it doesn't seem like <code>rawUploads</code> depends on <code>generatePreview</code>, I guess CF needs to know what lambda to trigger when creating the bucket, even though the trigger is defined in the lambda part of the CloudFormation template.</p>
  
  <p>I've found some resources online that talk about a similar issue, but it doesn't seem to apply here. <a href="https://aws.amazon.com/premiumsupport/knowledge-center/unable-validate-circular-dependency-cloudformation/" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/unable-validate-circular-dependency-cloudformation/</a> </p>
  
  <p>What are my options for breaking this circular dependency chain? Scriptable solutions are viable, but multiple deployments with manual changes are not for my use case.</p>
  
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: 'AWS::Serverless-2016-10-31'
  Resources:
    rawUploads:
      Type: 'AWS::S3::Bucket'
    previewAudioFiles:
      Type: 'AWS::S3::Bucket'
  
    generatePreview:
      Type: AWS::Serverless::Function
      Properties:
        Handler: generatePreview.handler
        Runtime: nodejs6.10
        CodeUri: .
        Environment:
          Variables:
            PipelineId: !Ref previewPipeline
        Events:
          BucketrawUploads:
            Type: S3
            Properties:
              Bucket: !Ref rawUploads
              Events: 's3:ObjectCreated:*'
  
    previewPipeline:
      Type: Custom::ElasticTranscoderPipeline
      Version: '1.0'
      Properties:
        ServiceToken:
          Fn::Join:
          - ":"
          - - arn:aws:lambda
            - Ref: AWS::Region
            - Ref: AWS::AccountId
            - function
            - aws-cloudformation-elastic-transcoder-pipeline-1-0-0
        Name: transcoderPipeline
        InputBucket:
          Ref: rawUploads
        OutputBucket:
          Ref: previewAudioFiles
  </code></pre>