官术网_书友最值得收藏!

Infrastructure as a Code

In the previous chapter, we looked at the basics of AWS Lambda, starting with creating an AWS account to develop our first micro function. However, our deployment process was pretty manual and obviously not production-ready. Based on the principle of "if you repeat a task three times, it's time to automate", it is time to automate this process in order to build a first-class deployment process that will automate and facilitate our workflow.

If you have ever used AWS Lambda in other languages, you might have heard about some frameworks such as Serverless, Apex, or Kappa. These are valuable open source tools with great features, and they used to be very essential for AWS Lambda development with features such as packaging the code, creation of API Gateway endpoints, and so on. If you are authoring Lambda functions in JavaScript or Python, it is recommended that you leverage one of these frameworks. However, in the Java platform, we have already been using strong build tools, such as Maven or Gradle. If you are a Java person, with Gradle, we get rid of the complication of the build process and packaging artifacts. After we compile our code to a single fat JAR file, the next step would be to create AWS Lambda functions using them and create the API Gateway resources and methods. Until a few months ago, the mentioned tools were the easiest way to create these cloud resources, but with the latest developments of AWS, we do not need these tools anymore: CloudFormation is the default offering from AWS that meets all the requirements. At the end of the day, just using Gradle and CloudFormation, we can create our handcrafted automated build mechanism for any Serverless application.

Some of my colleagues have been criticizing me because I am ignoring the open source frameworks and reinventing the wheel with a custom build mechanism. This is a pretty subjective topic, and everybody may have a different option. If we can develop our own build system easily, as we are going to see in this chapter, I do not see any benefit of depending on a third-party tool and inheriting their complexity and possible problems. For Java, I prefer pure Java solutions, and at the moment, I want to teach you how we can deploy to AWS without the aid of third-party tools. I believe that in this way, you are going to learn about the internals of AWS more deeply

In this chapter, we will meet with CloudFormation, the legendary tool of AWS that automates the cloud resources with JSON templates. CloudFormation will be one of the main tools we will use in this book, and it is maybe the most important AWS tool ever. I personally believe that.

In this journey, first, we will extend our build phase and add a functionality to our Gradle build script to upload compiled JAR files to AWS S3 storage. Once we have our artifacts in the cloud, the Gradle build script will install our handcrafted CloudFormation template to our AWS account. At the end of the chapter, we will have a single command to rule all. It will execute all the tests, build the artifacts, upload them to the cloud, and finally, deploy our application.

CloudFormation may seem a bit complicated in the beginning, but we will try to explain the concepts as clearly as possible and refer to the relevant documentation as much as possible.

We will cover the following topics in this chapter:

  • Uploading the artifacts to cloud
  • Infrastructure as code with CloudFormation
  • Deploying our first Lambda with CloudFormation
主站蜘蛛池模板: 土默特右旗| 建昌县| 五大连池市| 桂林市| 富源县| 洛宁县| 普兰店市| 札达县| 大悟县| 临汾市| 东乡县| 买车| 罗定市| 介休市| 云安县| 中宁县| 于都县| 大埔区| 太湖县| 巫溪县| 长宁区| 内丘县| 观塘区| 永宁县| 东乡族自治县| 大石桥市| 洪洞县| 黔东| 舟山市| 吉安县| 扎鲁特旗| 虹口区| 丰台区| 改则县| 即墨市| 贵港市| 永定县| 金坛市| 巍山| 保靖县| 恭城|