Is it possible to order Source actions in CodePipeline?

对着背影说爱祢 提交于 2021-02-17 05:19:31

问题


I have two different sources in my CodePipeline, ECR and S3. My deployment pipeline uploads a zip to S3, and then an image to ECR.

I need CodePipeline to detect just the ECR commit, which happens last, and then trigger the S3 source action. However whichever one is detected first starts the CodePipeline, which leads to a race condition in which the image for the new version hasn't been uploaded yet.

How can I resolve this? I cannot move S3 out of the Source stage, as per CodePipeline limitations. I've tried moving this S3 download to a Lambda function, but I can't seem to pass the zip back to CodePipeline as an output artifact.


回答1:


As trigger for the CodePipeline to run, define the CloudWatch event trigger only for ECR, not for S3 changes. Disable the Pipeline built-in trigger/pull.

https://docs.aws.amazon.com/codepipeline/latest/userguide/create-cwe-ecr-source-console.html This will make sure only ECR triggers a pipeline execution.




回答2:


If the intended way is to have the ECR commit processed along with whatever is uploaded to your S3, and assuming it's a new version of the exact same object name, you could get that data into your Build stage of your Pipeline, pulling the latest version like you tried with the Lambda function; or have some alternative way to identify that new S3 object.

If you're uploading the zip content to S3 and then committing the ECR push, you definitely could move the S3 bucket out of the Source stage and have it be somewhat independent as far as the Pipeline and triggers are concerned. It'll be another step in your Build project at the appropriate phase.



来源:https://stackoverflow.com/questions/64542844/is-it-possible-to-order-source-actions-in-codepipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!