[英]AWS Lambda for CodeCommit repo sync
I want to mirror my Bitbucket repository to CodeCommit and build from it, without affecting developer's workflow. 我想将我的Bitbucket存储库镜像到CodeCommit并从中构建,而又不影响开发人员的工作流程。 Migration is easy, now the goal is to sync CodeCommit with Bitbucket, ideally, triggered by pushing to Bitbucket, but time-based sync is also acceptable.
迁移很容易,现在的目标是将CodeCommit与Bitbucket同步,理想情况下是通过推送到Bitbucket触发的,但是基于时间的同步也是可以接受的。
I found this post: https://aws.amazon.com/blogs/devops/replicating-and-automating-sync-ups-for-a-repository-with-aws-codecommit/ and unanswered question here Mirror a Git Repo directly to AWS CodeCommit 我发现了这篇文章: https : //aws.amazon.com/blogs/devops/replicating-and-automating-sync-ups-for-a-repository-with-aws-codecommit/ ,这里没有答案, 直接镜像Git存储库到AWS CodeCommit
Please, share you ideas how to write aws lambda function to sync CodeCommit repository with Bitbucket. 请与您分享如何编写aws lambda函数以将CodeCommit存储库与Bitbucket同步的想法。
While I haven't tried this, I suspect the following workflow could work. 虽然我还没有尝试过,但是我怀疑下面的工作流程可以工作。 The general idea would be to use the BitBucket webhooks feature to trigger the lambda function through the use of API gateway.
一般的想法是使用BitBucket Webhooks功能通过使用API网关来触发lambda函数。
Write a Lambda function which 'mirror' clones from your bitbucket repository url and pushes to your CodeCommit repository url. 编写一个Lambda函数,该函数“镜像”从您的Bitbucket存储库URL克隆并推送到您的CodeCommit存储库URL。 Your function would likely need to include its own standalone git client library.
您的函数可能需要包括自己的独立git客户端库。
Create an API using API gateway which calls your lambda function. 使用调用您的lambda函数的API网关创建一个API。 Potential challenges here might be verifying that POST requests going to your API are coming from Bitbucket, and not some other source.
这里的潜在挑战可能是验证去往您的API的POST请求是否来自Bitbucket,而不是其他来源。
Create a new webhook for your Bitbucket repository with the URL being the url of your API you created in step 2. A 'Repository push' trigger would be sufficient to trigger a replication event after each push. 为您的Bitbucket存储库创建一个新的Webhook,URL为您在步骤2中创建的API的URL。“存储库推送”触发器足以在每次推送后触发复制事件。
One option is to use CodePipeline. 一种选择是使用CodePipeline。 Unfortunately with CodePipeline there is currently a weird process in making a Lambda function work as the sole process for the pipeline.
不幸的是,使用CodePipeline,使Lambda函数作为管道的唯一过程目前存在一个怪异的过程。 Basically it comes down to:
基本上可以归结为:
Another option is to use CloudWatch scheduling to invoke the Lambda at X interval if you're okay with a more delayed sync. 另一个选择是,如果可以延迟更长时间的同步,则可以使用CloudWatch调度以X间隔调用Lambda。 This will probably be easier to setup in the long run, with the possibility of having null Lambda runs if there's nothing to sync, counting against your allocation.
从长远来看,这可能会更容易设置,并且如果没有什么要同步的话,有可能使Lambda空运行,这会算作您的分配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.