Giter VIP home page Giter VIP logo

cloudformal's Introduction

Cloudformal

A type-safe CloudFormation DSL written in Scala, which you can apply changes casually!

Motivation

In this DevOps and Infrastructure as Code age, Infrastructure automation is unavoidable. Such a automation has a dangerous pitfall - if something goes wrong in automated operation, the automation can cause devastating effect, such as sweeping all of your production servers.

What can we do now? My idea is to enforce strict type-checking to infrastructure codes in compile time, before we ship it to production, making use of Scala's powerful type-system.

How to use

  1. First, you have to compile cloudformal locally(until forthcoming maven release, at least):

    git clone [email protected]:mshibuya/cloudformal.git
    cd cloudformal
    sbt publishLocal
    
  2. Create your sbt project:

    build.sbt

    lazy val root = (project in file(".")).
      settings(
        inThisBuild(List(
          organization := "com.example",
          scalaVersion := "2.12.5",
          version      := "0.1.0-SNAPSHOT"
        )),
        name := "your-project-name",
        libraryDependencies += "com.github.mshibuya" %% "cloudformal" % "0.1.0-SNAPSHOT"
      )
    

    src/main/scala/com/example/Main.scala

    package com.example
    
    import com.github.mshibuya.cloudformal.CLI
    
    object Main extends CLI {
      def main(args: Array[String]): Unit = run(args)
    }
    
  3. Describe your CloudFormation stacks:

    src/main/scala/com/example/YourStack.scala

    package com.example
    
    import com.github.mshibuya.cloudformal.aws.ec2
    import com.github.mshibuya.cloudformal.model._
    
    object YourStack extends Stack {
      val name = "YourStack"
      val description = "Example stack"
    
      val parameters = Nil
      val mappings = Nil
      val myServer = new ec2.Instance {
        val logicalId = "MyServer"
        val imageId = Value("ami-97785bed")
      }
      val resources = Seq(myServer)
      val outputs = Nil
    }
    
  4. Running sbt run convert com.example.YourStack will produce the CloudFormation template output.

    {
      "AWSTemplateFormatVersion" : "2010-09-09",
      "Description" : "Example stack",
      ...
    }
    

Alternatives

A young(it has almost the same birthday with ours), promising new CloudFormation DSL, utilizing TypeScript's robust type system and JSON friendliness.

It was written in Scala like us, but comes with no auto-generation from AWS's CloudFormation resource specification, which makes it harder to keep up to CloudFormation new features and updates. It's use case classes with resource representation leads to less margin of using user-defined type constraint, IMHO.

License

MIT

cloudformal's People

Contributors

mshibuya avatar

Watchers

kenji yoshida avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.