Does AWS SAM CodePipelines do whole rebuild per commit?

做~自己de王妃 提交于 2019-12-11 14:48:27

问题


I am building a distributed app in AWS consisting of base resource (iam etc), data-warehousing but mostly serverless resources like lambdas, sns, mongodb,..

For deploying this over an OTAP I am looking into AWS tooling for this, mostly outlined here.

This means that the 1 repo in CodeCommit will trigger the CodePipeline, which will have these components in de right places (realizing order control):

  • deploying CF stacks
  • using CodeBuild to package (AWS sam package) a SAM resource-> for every SAM resource one
  • using a build step to create a change set -> one per SAM resource
  • using a build step to execute a change set -> one per change-set

So as an example, I will need a buildspec.yml for every lambda beside the .js file for that lambda and also the lambda will need to be constructed in a SAM template (its own or a grouped one). Also a build-change-set step and execute-change-set step for each.

My question: If in this setup, for 1 repo for the whole distributed app, I change 1 tiny dumb thing like the time-out of 1 of the many lambdas, will this rebuild en redeploy all elements of the app?

If no, thank god, but how does it work? CodeCommit sends a whole zip of all sources to S3, NOT changes only. So all elements will be triggered and during de deployments of a stack (CF or SAM) the underlying tech could be smart and only do what needs to be changed. But still, all elements in CodePipeline (and there are many) will be triggered which is inefficient where the goal is to finish the whole deployment as fast as possible.

If yes, well that would suck and I would then find another solution with custom code (lambdas) in the pipeline extracting changes only from CodeCommit API and do cretae-change-set and execute. Using aws sdk with main drawback giving in on order control and some things like "aws sam package" are not available in sdk.


回答1:


@TimR If you have 10's of resources you don't want to rebuild/redeploy them in P if not needed. That is very bad. Each resource needs max uptime.

To answer my own question, When using codePipeline or whatever to deploy changes, it will check the whole template(s) for what is different and depending on the resource type and what has changed redeploy that resource. Non changed resources are only checked but mostly untouched. So this is good only thing is that all actions in the whole CodePipeline will be triggered taking a lot of time besides that CP is Async arch and therefore also quit slow. A mid size one takes around 10 minutes for a small change. Now say you have 10-20 dev committing every 30 minutes..

SAM/Lambdas however has a bug in AWS. When using MD5 calculation of the Lambda code it checks whether to update/redeploy the lambda. The algorithm takes into account file properties like last changed etc resulting in concluding that all lambdas have changed which is stupid.



来源:https://stackoverflow.com/questions/50316886/does-aws-sam-codepipelines-do-whole-rebuild-per-commit

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