CloudFormation-Builder is a Java 8 DSL for creating AWS CloudFormation templates.
Use jitpack to import this project as a maven dependency.
<dependency>
<groupId>com.github.StuPro-TOSCAna</groupId>
<artifactId>cloudformation-builder</artifactId>
<version>{releaseVersion/commitHash}</version>
</dependency>
Use a release version or simply the hash of a commit to specify the version.
CloudFormation templates are built within a so-called Module
. This module gets filled with all the CloudFormation resources needed to build the template.
The following is a quick example on how a CloudFormation template is built with the CloudFormation Builder:
class Ec2withEbsModule extends Module {
public void build() {
this.template.setDescription("Ec2 block device mapping");
EC2EBSBlockDevice ec2EBSBlockDeviceA = new EC2EBSBlockDevice()
.volumeType("io1")
.iops(200)
.deleteOnTermination(false)
.volumeSize("20");
EC2BlockDeviceMapping ec2BlockDeviceMappingA = new EC2BlockDeviceMapping()
.deviceName("/dev/sdm")
.ebs(ec2EBSBlockDeviceA);
EC2BlockDeviceMapping ec2BlockDeviceMappingB = new EC2BlockDeviceMapping()
.deviceName("/dev/sdk")
.noDevice(false);
resource(Instance.class, "MyEC2Instance")
.imageId("ami-79fd7eee")
.keyName("testkey")
.blockDeviceMappings(ec2BlockDeviceMappingA, ec2BlockDeviceMappingB);
}
}
Note: The example is taken from the
InstanceTest
. See/src/test/java/com/scaleset/cfbuilder/
for more tests containing examples that you can use.
This Ec2withEbsModule
results in the following CloudFormation template:
AWSTemplateFormatVersion: "2010-09-09"
Description: "Ec2 block device mapping"
Resources:
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-79fd7eee"
KeyName: "testkey"
BlockDeviceMappings:
- DeviceName: "/dev/sdm"
Ebs:
DeleteOnTermination: false
Iops: 200
VolumeSize: "20"
VolumeType: "io1"
- DeviceName: "/dev/sdk"
NoDevice: false
See our contribution guidelines for detailed information on how to contribute to the cloudformation-builder.
Tools that are used in this project.
- IDE: IntelliJ
- Code generation: Project Lombok
- UML Modelling: Lucidchart
- Project management: ZenHub
- CI: TravisCI
- Code analysis: Codacy
- Code coverage: Codecov, Get browser extension
CloudFormation-Builder is licensed under the Apache License 2.0.