title: How to export an existing CodePipeline to CloudFormation template
body: <p>This is more of a lack of understanding on my part but I cannot seem to debug this.
  I have created an codepipeline which runs terraform apply ( which internally creates the aws infrastructure for me ). the codepipeline seems to be working.</p>
  <p>I need to implement the same codepipeline for another account, how can I do so.</p>
  <p>I tried to get the json script using the below command.
  <code>aws codepipeline get-pipeline --name</code></p>
  <p>I convert json script to yaml script.</p>
  <p>When I try to run the yaml script on another account I get below error</p>
  <p><code>Template format error: At least one Resources member must be defined.</code></p>
  <p><strong>ISSUES</strong>:
  1.) Best Way I can export codepipeline to cloudformation template
  2.) The approach which I used didn't work, how to solve it?</p>
  <pre class="lang-html prettyprint-override"><code>{
      &quot;pipeline&quot;: {
          &quot;name&quot;: &quot;my-code-pipeline&quot;,
          &quot;roleArn&quot;: &quot;arn:aws:iam::aws-account-id:role/service-role/AWSCodePipelineServiceRole-aws-region-my-code-pipeline&quot;,
          &quot;artifactStore&quot;: {
              &quot;type&quot;: &quot;S3&quot;,
              &quot;location&quot;: &quot;codepipeline-aws-region-45856771421&quot;
          },
          &quot;stages&quot;: [
              {
                  &quot;name&quot;: &quot;Source&quot;,
                  &quot;actions&quot;: [
                      {
                          &quot;name&quot;: &quot;Source&quot;,
                          &quot;actionTypeId&quot;: {
                              &quot;category&quot;: &quot;Source&quot;,
                              &quot;owner&quot;: &quot;ThirdParty&quot;,
                              &quot;provider&quot;: &quot;GitHub&quot;,
                              &quot;version&quot;: &quot;1&quot;
                          },
                          &quot;runOrder&quot;: 1,
                          &quot;configuration&quot;: {
                              &quot;Branch&quot;: &quot;master&quot;,
                              &quot;OAuthToken&quot;: &quot;****&quot;,
                              &quot;Owner&quot;: &quot;github-account-name&quot;,
                              &quot;PollForSourceChanges&quot;: &quot;false&quot;,
                              &quot;Repo&quot;: &quot;repo-name&quot;
                          },
                          &quot;outputArtifacts&quot;: [
                              {
                                  &quot;name&quot;: &quot;SourceArtifact&quot;
                              }
                          ],
                          &quot;inputArtifacts&quot;: [],
                          &quot;region&quot;: &quot;aws-region&quot;,
                          &quot;namespace&quot;: &quot;SourceVariables&quot;
                      }
                  ]
              },
              {
                  &quot;name&quot;: &quot;codebuild-for-terraform-init-and-plan&quot;,
                  &quot;actions&quot;: [
                      {
                          &quot;name&quot;: &quot;codebuild-for-terraform-init&quot;,
                          &quot;actionTypeId&quot;: {
                              &quot;category&quot;: &quot;Build&quot;,
                              &quot;owner&quot;: &quot;AWS&quot;,
                              &quot;provider&quot;: &quot;CodeBuild&quot;,
                              &quot;version&quot;: &quot;1&quot;
                          },
                          &quot;runOrder&quot;: 1,
                          &quot;configuration&quot;: {
                              &quot;ProjectName&quot;: &quot;my-code-pipeline-build-stage&quot;
                          },
                          &quot;outputArtifacts&quot;: [],
                          &quot;inputArtifacts&quot;: [
                              {
                                  &quot;name&quot;: &quot;SourceArtifact&quot;
                              }
                          ],
                          &quot;region&quot;: &quot;aws-region&quot;
                      }
                  ]
              },
              {
                  &quot;name&quot;: &quot;manual-approve&quot;,
                  &quot;actions&quot;: [
                      {
                          &quot;name&quot;: &quot;approval&quot;,
                          &quot;actionTypeId&quot;: {
                              &quot;category&quot;: &quot;Approval&quot;,
                              &quot;owner&quot;: &quot;AWS&quot;,
                              &quot;provider&quot;: &quot;Manual&quot;,
                              &quot;version&quot;: &quot;1&quot;
                          },
                          &quot;runOrder&quot;: 1,
                          &quot;configuration&quot;: {
                              &quot;NotificationArn&quot;: &quot;arn:aws:sns:aws-region:aws-account-id:Email-Service&quot;
                          },
                          &quot;outputArtifacts&quot;: [],
                          &quot;inputArtifacts&quot;: [],
                          &quot;region&quot;: &quot;aws-region&quot;
                      }
                  ]
              },
              {
                  &quot;name&quot;: &quot;codebuild-for-terraform-apply&quot;,
                  &quot;actions&quot;: [
                      {
                          &quot;name&quot;: &quot;codebuild-for-terraform-apply&quot;,
                          &quot;actionTypeId&quot;: {
                              &quot;category&quot;: &quot;Build&quot;,
                              &quot;owner&quot;: &quot;AWS&quot;,
                              &quot;provider&quot;: &quot;CodeBuild&quot;,
                              &quot;version&quot;: &quot;1&quot;
                          },
                          &quot;runOrder&quot;: 1,
                          &quot;configuration&quot;: {
                              &quot;ProjectName&quot;: &quot;codebuild-project-for-apply&quot;
                          },
                          &quot;outputArtifacts&quot;: [],
                          &quot;inputArtifacts&quot;: [
                              {
                                  &quot;name&quot;: &quot;SourceArtifact&quot;
                              }
                          ],
                          &quot;region&quot;: &quot;aws-region&quot;
                      }
                  ]
              }
          ],
          &quot;version&quot;: 11
      },
      &quot;metadata&quot;: {
          &quot;pipelineArn&quot;: &quot;arn:aws:codepipeline:aws-region:aws-account-id:my-code-pipeline&quot;,
          &quot;created&quot;: &quot;2020-09-17T13:12:50.085000+05:30&quot;,
          &quot;updated&quot;: &quot;2020-09-21T15:46:19.613000+05:30&quot;
      }
  }
  </code></pre>
  
  <p>The given code is the yaml template that I used to create cloudformation template.</p>