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

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
主站蜘蛛池模板: 集安市| 浦北县| 夏邑县| 永嘉县| 开远市| 东港市| 桐城市| 噶尔县| 青河县| 华坪县| 鸡东县| 竹北市| 龙陵县| 大关县| 武城县| 黄山市| 当雄县| 遂宁市| 塔河县| 会宁县| 宝兴县| 海宁市| 阿拉尔市| 连平县| 民和| 龙川县| 桑日县| 赞皇县| 池州市| 汨罗市| 陇南市| 治多县| 邢台市| 潍坊市| 九龙县| 潞西市| 军事| 田林县| 易门县| 满城县| 义马市|