How to pass input from EventBridge rule to CodePipeline as a dynamic variable


Hi, I've been needing to pass in a variable to CodePipeline when my EventBridge rule picks up when a specific tag is pushed in my CodeCommit repo. My EventBridge event pattern is below

  "source": ["aws.codecommit"],
  "detail-type": ["CodeCommit Repository State Change"],
  "resources": ["arn:aws:codecommit:<region>:<id>:<repo>"],
  "detail": {
    "event": ["referenceCreated", "referenceUpdated"],
    "repositoryName": ["<repo>"],
    "referenceType": ["tag"],
    "referenceName": [{
      "prefix": "abc"

I have one target, which is pointing at my CodePipeline. I have defined an input transformer where the input path is

  "tag": "$.detail.referenceName"

and the input template is

   "defaultValue": "<tag>",
   "description": "variable passed by eventbridge trigger",
   "name": "IMAGETAG"

I defined the input template using this link, I want it to update the pipeline with a pipeline level variable based off the reference name matched in the event pattern.

In my pipeline's build phase, I have defined the environment variable to be used in my buildspec file:

name: IMAGETAG, value: #{variables.IMAGETAG}, type:PLAINTEXT

This isn't working because the pipeline hasn't been updated with the variable set by EventBridge. I haven't seen many examples of this specifically. Any help is appreciated. Thanks!

1 Answer


This article is doing something very similar to what you want to achieve:

You may want to follow its guidance.


profile pictureAWS
answered 17 days ago
profile picture
reviewed 17 days ago
  • Hi, That article is only for using a Github source; I am using a CodePipeline source, pointing to a CodeCommit repo.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions