title: My CloudWatch Event rule doesn't trigger my CodePipeline pipeline
body: <p>I'm having some issues with AWS CloudWatch Events.</p>
  
  <p>I'm creating a CodePipeline CI pipeline which have a CodeCommit repository as the Source, a CodeBuild project as the Build/Test phase (then, it deploys to Lambda, but the problem isn't there).</p>
  
  <p>We have multiple projects and we are going to push multiple other projects. So, I created a script that manages the AWS CI stuff (i.e. creating a pipeline, a CodeBuild project, ... AND a CloudWatch Events rule, linked to the pipeline).</p>
  
  <p>The first time I push my code, it works. But then, the process stop getting triggered by the push on CodeCommit.</p>
  
  <p>I found a solution (but NOT the one I want) : I just have to modify the pipeline, modify the stage (Source), not touching anything, and saving the null modification : and it works (before saving, it ask the authorization to create a CloudWatch Events rule associated with this pipeline).</p>
  
  <p>Does somebody encountered this issue ? What did you do to bypass it ?
  I really want to make a 100% automated CI, I don't want to go to the AWS Console each time my team create a new repository or push a new branch on an existing repository.</p>
  
  <p>EDIT :</p>
  
  <p>Here is the JSON of my CloudWatch Events rule :</p>
  
  <pre><code>{
      "Name": "company-ci_codepipeline_project-stage", 
      "EventPattern": "cf. second JSON", 
      "State": "ENABLED", 
      "Arn": "arn:aws:events:region:xxx:rule/company-ci_codepipeline_project-stage", 
      "Description": "CloudWatch Events rule to automatically trigger the needed pipeline from every push to project repository, on the stage branch on CodeCommit."
  }
  </code></pre>
  
  <p>And here is the <code>EventPattern</code> JSON :</p>
  
  <pre><code>{
    "source": [
      "aws.codecommit"
    ],
    "detail-type": [
      "CodeCommit repository state change"
    ],
    "resources": [
      "arn:aws:codecommit:region:xxx:project"
    ],
    "detail": {
      "event": [
        "referenceCreated",
        "referenceUpdated"
      ],
      "referenceType": [
        "branch"
      ],
      "referenceName": [
        "stage"
      ]
    }
  }
  </code></pre>