Infrastructure as Code is the practice of managing and provisioning infrastructure as developers manage application code. Instead of configuring and managing infrastructure manually through the console, SDK, CLI, Infrastructure as Code allows for creation, deployment and maintenance of the infrastructure in a programmatic, descriptive, declarative way. This creates modular and reusable components, promoting efficiency, consistency and reducing duplicate efforts. Following the same rigor of application code development to infrastructure provisioning, all configurations containing infrastructure specifications should be defined in a declarative standard, defined under a source control or version management system.
Here are some of the mechanisms to define Serverless Java applications' Infrastructure as Code:
AWS CloudFormation is a service
that allows developers to define and provision infrastructure
in a template-based approach.
The resources along with their dependencies are defined in text files in JSON
or YAML
format.
The template requires a specific syntax and structure, depending on the types of resources being defined.
This template defines a collection of resources as a single unit called a Stack.
The CloudFormation Command Line Interface (CFN-CLI) is an open-source tool that enables you to develop and test AWS and third-party extensions. An extension is an artifact, registered in the CloudFormation registry, which augments the functionality of CloudFormation in a native manner. The CloudFormation registry lets you manage extensions, both public and private, such as resources, modules, and hooks that are available for use in your AWS account. The extension types in AWS registry are: resources types, modules, and hooks.
The CloudFormation CLI can be installed using pip from the Python Package Index (PyPI). Refer to this GitHub repository to install the development plugin for Java.
pip3 install cloudformation-cli-java-plugin