Introduction to each tool of 1610797f8e25cd requires a growth process, and Serverless Devs is constantly growing.
Since I started working on serverless tools, I have often encountered a question that people ask: how to ensure the consistency of serverless business deployment updates.
The so-called consistency here refers to: we deploy the project locally through tools, and at this time someone has updated the project through other means (such as the console, etc.), and then I deploy the project locally , Will it be directly covered?
For example, when user A updates the business locally, due to some special circumstances, an online abnormal situation "x" occurs. At this time, user B updates again and fixes the content, but B does not synchronize to A in time. , A has been updated with new functions, directly covering the content of B. At this time, the previous abnormal x appears again. If at this time, when A is updated, you can perceive that online resources have changed, then this kind of thing is not Will happen again.
At present, the Alibaba Cloud function computing component based on Serverless Devs has supported the perception of online "transitions", including the following situations:
- Create and deploy a resource that is not available online
- Local deployment is complete, online update, local deployment again
- Create and deploy an existing online resource locally
Experiment preparation
Create a function through s init (choose Alibaba Cloud Serverless, choose HTTP Function-Python3 Example):
At this point we check s.yaml:
The performance of the project after it is deployed online is to create a fc-deploy-service service and http-trigger-function function in the cn-hangzhou area
Create and deploy a resource that is not available online
At this point, we make sure that there is no corresponding resource online, so we deploy it:
The deployment is complete and very smooth:
Open the browser and check the custom address sent back to us:
At this point, we can update the function code locally:
Save the deployment:
After finishing, check the online resources:
The whole process is still relatively close to the traditional basic process, and no online changes are triggered. It is an ideal process that is quite satisfactory.
Local deployment is complete, online update, local deployment again
At this point, we make changes to the online resources, first find the function in the console:
Modify the code and deploy.
After the deployment is complete, we refresh the address just now:
You can see that it has been updated. At this point, we deploy from the local:
As you can see, the system has sensed our code changes. At this time, we choose yes, and after completion, we will check the online resources:
What needs to be added here is that as long as it is a function computing service, function, and trigger, it can be sensed here, whether it is configuration or code.
Create and deploy an existing online resource locally
At this point, we will carry out the final experiment, we will delete the local project and rebuild it. Then perform the deployment. Due to the reasons we have just experimented, we already have these resources online, so it is considered to deploy an online resource at this time.
At this point, you can see that the system perceives that this resource has not been deployed locally, it is online and already exists, so you need to determine whether to cover it at this time.
Summarize
The code is updated in other scenarios, and we need to be aware of it in the current situation. This matter is actually very important, and it is indispensable to the secure release of the code. At this time, it can be done through Serverless Devs.
So the question is, if I already have a project and I want to integrate it into the cd process, and I don't want interactive operations, how should I deal with it?
At this time, we provide a --use-local parameter to forcibly overwrite the online configuration. Through such a command, no interaction and local priority can be achieved.
The birth of every tool must have a growth process, and Serverless Devs are constantly growing. Looking forward to more and better features.
Copyright Notice: content of this article is contributed spontaneously by Alibaba Cloud real-name registered users, and the copyright belongs to the original author. The Alibaba Cloud Developer Community does not own its copyright and does not assume corresponding legal responsibilities. For specific rules, please refer to the "Alibaba Cloud Developer Community User Service Agreement" and the "Alibaba Cloud Developer Community Intellectual Property Protection Guidelines". If you find suspected plagiarism in this community, fill in the infringement complaint form to report it. Once verified, the community will immediately delete the suspected infringing content.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。