AWS EventBridge do not send image_push event to Uffizzi

Viewed 35

I try to setup CP process according to this docs:

I created IAM user and EventBridge rule and connect my ECR registry to Uffizzi.

Stage that push MR image in my gitlab-ci.yml looks like this:

push_preview_container:
    <<: *on_project_runner
    <<: *with_docker_service
    <<: *with_docker_compose
    variables:
      GIT_STRATEGY: none
      APP_IMAGE: $PROJECT_ECR_URL
      VERSION: $CI_COMMIT_SHA
      MR_IID: $CI_MERGE_REQUEST_IID
    stage: push_preview_container
    image: $TOOLBOX_IMAGE
    only:
      - merge_requests
    script:
      - ecs_helper ecr_login
      - docker pull "${APP_IMAGE}:${VERSION}"
      - docker tag "${APP_IMAGE}:${VERSION}" "${APP_IMAGE}:uffizzi_request_${MR_IID}"
      - docker push "${APP_IMAGE}:uffizzi_request_${MR_IID}"

The problem is that EventBridge do not send event(webhook) to Uffizzi when MR image pushed. It send event(webhook) only on branch CI/CD pipeline.

  • On my CI/CD pipelines for branches EventBridge successfully send image_pushed event(webhook).

But when I create MR it do the next steps:

  • My push_preview_container stage runs, and jobs ends with success

[push_preview_container stage][1] [1]: https://i.stack.imgur.com/8lRyU.png

  • This push adds :uffizzi_request_ tag to image in my ECR
  • But for some reason, it does not trigger the image_pushed rule and nothing sends to Uffizzi
1 Answers

The problem was caused by ECR optimization. When you push the image, ECR first checks if an image with the same SHA exists in the registry. And if it exists ECR does not really push the image but just adds a new tag. And in this case, the EventBridge rule does not send an event. Because there was no push, but tag adding. If you have the same problem you need re-build your image to recalculate its SHA.

Like This:

script:
    - ecs_helper ecr_login
    - docker build --tag="${APP_IMAGE}:uffizzi_request_${MR_IID}" .
    - docker push "${APP_IMAGE}:uffizzi_request_${MR_IID}"
Related